Skip to content

Cheatsheet

Rob Yang edited this page Feb 11, 2019 · 38 revisions

git

COMMAND ACTION
git push origin HEAD Push current branch to same name on remote
git branch -m [old name] [new name] Rename any branch
git branch -m [new name] Rename current branch
git remote prune origin Prune branches
git rebase -i master Squash commits
git rebase -p --onto [SHA]^ [SHA] Delete commit
git cherry-pick [SHA of commit to cherry-pick] Cherry pick commit into current branch
git reset --soft HEAD^ Uncommit the last commit
git reset -p [filename] Unstage hunks from file
git checkout -- [filename]
git checkout [path/to/filename]
Clear unstaged changes from file
git clean -df Clear all unstaged directories and files
git stash Stash changes
git stash list View list of stashed changes
git stash apply [thing from list] Restore stashed change
git stash drop Drop top stash
git submodule add [url_to_repo] [repo] Add repo as submodule within a repo
git submodule init Initialize existing submodules in repo
git submodule update Downloads submodule repos
git ls-files --stage Show staged submodules in index
git rm --cached [repo] Unstage the repo from the index
git commit --amend Change commit message
git show-ref --tags Show all tags/refs
git ls-remote --tags Show all tags/refs on remote
git tag -a [deploy date and version] Create tag, eg. 20170118v1
git push origin --tags Push tags to GitHub repo
git tag -d 12345 Delete local tag
git push origin :refs/tags/12345 Delete remote tag
git diff master..[branch] View all code differences from master
git diff --name-status master..[branch] View all files different from master

vim

SHORTCUT ACTION
1. control+V
2. Select text
3. C
4. Type your changes
5. esc
Replace column of text
U Undo
ctrl+R Redo
shift+O Insert line above
O Insert line below
^ or 0 Go to beginning of line
shift+I Go to beginning of line and edit
$ Go to end of line
shift+A Go to end of line and edit
1. DD
2. Move cursor to line
3a. P to paste line after cursor
3b. shift+P to paste line before cursor
Move line of text to different line
CS"``' "Hello world!" to 'Hello world!'
CS'``<q> 'Hello world!' to <q>Hello world!</q>
DS" "Hello world!" to Hello world!
1. Put cursor on Hello
2. YSIW] (iw is a text object)
Hello world! to [Hello] world!
:help NERDTreeMappings Show all keyboard mappings
T Open the selected file in a new tab
I Open the selected file in a horizontal split window
S Open the selected file in a vertical split window
shift+I Toggle hidden files
M Show the NERD Tree menu
shift+R Refresh the tree, useful if files change outside of Vim
? Toggle NERD Tree's quick help
GT Next tab (NERDTree)
Gshift+T Previous tab (NERDTree)

sublime

SHORTCUT ACTION
shift+command+space Select between brackets
shift+command+K Select to open/closing tags
control+D Select between tags
control+shift+W Wrap line/selection with tag

terminal

COMMAND ACTION
lsof -i tcp:9292 list all processes running on port 9292
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
download pathogen
rm -rf directoryname Delete directory and all its contents
mv **/*.zip /path/to/single/target/directory Move file type to another directory
kill %[JOB_ID] Kill job based on number
fg %[JOB_ID] Bring job to foreground based on number
SHORTCUT ACTION
Control + W Deletes the word immediately before the cursor
Alt + D Deletes character immediately after the cursor
Control + A Moves cursor to the beginning of the line
Control + E Moves cursor to the end of the line
Control + U Clears the entirety of the line before the cursor
Control + K Clears the line that appears after the cursor
Command + K
or
Control + L
Clears the entire Terminal screen

Clone this wiki locally