Last active
August 29, 2015 14:00
-
-
Save Fintan/11232726 to your computer and use it in GitHub Desktop.
Git commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git status (shows the status of changes on each tree of current branch) | |
| git add -i (interactive mode) | |
| git add -u (adds all tracked files) | |
| git add . (also adds deleted files) | |
| git diff (diff of what is changed but not staged) | |
| git diff --staged (diff of what is staged but not yet committed) | |
| git reset [file] (unstage a file) | |
| git rm [file] (unstage and remove a file from working directory) | |
| git reset HEAD -- (unstage files) | |
| git update-index --assume-unchanged [files] (omit files from git status listing) | |
| COMMITTED ON THE WRONG BRANCH? | |
| git branch featureBranch | |
| git reset --hard HEAD~1 | |
| git show --abbrev-commit --graph --decorate --oneline -2 | |
| git config --global alias.detail "show --abbrev-commit --graph --decorate" | |
| git log --all --pretty-oneline --abbrev-commit --graph --decorate | |
| git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" | |
| git push [origin] [master] (push commits, optionally specify alias and branch) | |
| conflicts: | |
| git mergetool -t diffmerge | |
| git rebase --continue (once all conflicts are resolved to your satisfaction, continue with rebase) | |
| git branch (list all branches, * beside active branch) | |
| git checkout [branch] | |
| git stash | |
| git stash apply | |
| git stash pop | |
| git tag -l -n1 (list git tags with their messages) | |
| git config --global alias.co checkout | |
| git diff: Show differences between your working directory and the index. | |
| git diff –cached: Show differences between the index and the most recent commit. | |
| git diff HEAD: Show the differences between your working directory and the most recent commit. | |
| VIM: | |
| ctrl+f (forward a page) | |
| ctrl+b (back a page) | |
| gg (move to first line) | |
| G (move to last line) | |
| nG (move to line n) | |
| vimdiff: | |
| git config merge.tool vimdiffgit config merge.conflictstyle diff3 git config mergetool.prompt false | |
| then: | |
| git difftool step1 step2 -- Layout.hbs (compare two versions of same file -different tags) | |
| git config --global user.name | |
| git config --global user.email | |
| git config --global color.ui auto (adds colour to terminal for diffs) | |
| Git Flow: | |
| git flow init | |
| git flow feature start [feature-branch-name] (create a feature branch from head of develop) | |
| git flow feature finish [feature-branch-name] (merges feature-branch-name back into develop) | |
| git flow release start v0.1.0 (create a release branch from head of develop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment