This is a draft cheat sheet. It is a work in progress and is not finished yet.
Basic
git checkout <branch> |
switch to <branch> |
git checkout -b <branch> |
create <branch> and switch to it |
git status |
show uncommited changes |
git add <file> |
add <file> changes to next commit |
git add . |
add all changes to next commit |
git commit |
commit selected changes |
git commit -amend |
commit selected changes overwritting last commit |
git merge <branch> |
merge <branch> into current branch |
Remote
git fetch <remote> |
fetch branches from <remote> |
git pull <remote> |
fetch branches and merge |
git push <remote> <branch> |
upload local <branch> to <remote> |
Reset
git reset --hard |
Undo last commit and delete changes |
git reset --soft |
Undo last commit keeping changes in working directory |
git reset <sha> |
Reset until commit <sha> |
git reset HEAD~<n> |
Reset <n> commits |
Stash
git stash |
stash changes from working directory |
git stash apply |
apply stashed changes to working directory |
git stash pop |
apply stashed changes to working directory and remove them from stash |
git stash drop |
remove stored changes from stash |
git stash clear |
clear all stashed changes |
CherryPick - Rebase
git cherry-pick <sha> |
apply <sha> commit into current branch |
git cherry-pick <sha> --no-commit |
apply <sha> commit into working directory |
git rebase <branch> |
apply current branch commits to <branch> head |
git rebase --interactive <branch> |
apply current branch commits to <branch> head one by one |
|