|
<branch_name>
|
Last commit on the branch
|
|
HEAD
|
Current commit (parent for next commit)
|
|
HEAD^
|
parent of HEAD
|
|
HEAD~n
|
n-th level parent of HEAD
|
|
HEAD@{n}
|
HEAD n moves ago (reflog)
|
|
SHA1 ID (4-20 characters)
|
Unique commit identifier
|
|
Create branch for new feature
git checkout develop
git checkout -b fb/new_feature_branch |
|
Add change
# make changes
make compile git status git add file.c git diff --cached (or --staged) git commit |
|
Rebase
git pull --rebase origin develop
|
|
Push unfinished feature branch at the EoD
git push origin fb/new_feature_branch -f
|
|
Merge with develop when finished
# ensure we’re rebased on latest develop
git checkout develop git pull git merge fb/new_feature_branch --no-ff |
|
Push develop
git push origin develop
|
|
Remove feature branch
git branch -d fb/new_feature_branch
git push origin :fb/new_feature_branch |
|
commit [-m "commit msg"]
|
Commit staged changes
|
|
commit -a
|
Add & commit all tracked files
|
|
commit --amend
|
Add changes to last commit
|
|
add [file]
|
Stage file
|
|
add -p
|
Add chunks interactively
|
|
diff --staged
|
Inspect staged changes
|
|
checkout .
|
Undo uncommited changes
|
|
reset HEAD
|
Unstage files
|
|
reset --soft HEAD^
|
Undo commit (to stage)
|
|
reset --hard HEAD^
|
Undo commit
|
|
revert <commit>
|
Revert existing commit
|
|
branch -avv
|
List all branches with refs
|
|
branch <name> [<commit>]
|
Create branch (at <commit>)
|
|
checkout -b <branch_name>
|
Create & checkout new branch
|
|
checkout <branch> [file]
|
Checkout workspace (or file)
|
|
branch -m <new_branch_name>
|
Rename current branch
|
|
branch -d|-D <branch>
|
Delete merged/unmerged branch
|
|
merge <with_branch>
|
Merge branch (default: fast-forward)
|
|
merge <with_branch> --no-ff
|
Merge branch (no fast-forward)
|
|
rebase <new_root_commit>
|
Rebase current branch
|
|
rebase -i <start_commit>
|
Interactive rebase
|
|
rebase -i HEAD~n
|
Interactive rebase (last n commits)
|
|
remote -v
|
Show all remotes
|
|
remote add <name> <url>
|
Add remote
|
|
remote remove <name>
|
Remove remote
|
|
fetch [<remote>]
|
Get remote changes
|
|
pull [<remote>]
|
Get & merge remote changes
|
|
pull --rebase [<remote>] [<branch>]
|
Get & rebase on remote changes
|
|
push [<remote>] [<branch>] [-f]
|
Push local branch to remote
|
|
push -n
|
Dry-run push
|
|
remote prune origin
|
Clean all old remote branch references
|
|
reset <mode> [<commit>]
|
Reset current branch to <commit>
|
|
reset --soft HEAD^
|
Undo commit
|
|
reset HEAD~n
|
Undo last n commits
|
|
cherry-pick <commit>
|
Apply already-existing change
|
|
rebase --onto <base> <start^> <end>
|
Apply set of already-existing changes
|
|
stash
|
Stash workdir & index
|
|
stash list
|
List stashes
|
|
stash pop [--index]
|
Apply & delete stash
|
|
stash apply [--index]
|
Apply stash
|
|
stash pop [stash@{n}]
|
Apply & delete n-th stash
|
|
stash drop [stash@{n}]
|
Remove n-th or latest stash
|
|
stash clear
|
Remove all stashes
|
|
stash branch [<new_branch>]
|
Create branch from a stash
|
|
tag
|
Liast tags
|
|
tag <tagname> [<commit>]
|
Add lightweight tag
|
|
tag -a <tagname> [-m “Tag message”]
|
Add annotated tag
|
|
tag -d <tagname>
|
Remove tag
|
|
push <remote> <tagname>
|
Push tag
|
|
push <remote> --tags
|
Push with all tags
|
|
push <remote> :<tagname>
|
Remove remote tag
|
|
blame <file> [-L start,stop]
|
Check who modified file (lines start-stop)
|
|
reflog
|
Show history of HEAD
|
|
branch <new_branch_name> <lost_commit>
|
Recover deleted branch
|
|
gc
|
Manually clean garbage objects
|
|
clean -fd
|
Remove not tracked files and folders
|
|
bisect start <bad_commit> <good_commit>
|
Init bisect
|
|
bisect run test_script.sh
|
Run automated binary-search
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.