Full list of Git commands: branches, commits, cherry-pick, rebase, stash and more
Git Cheatsheet ^-^
This is a complete guide with 100 Git commands.
From basics to advanced workflows β everything you need to feel like a Git Ninja π₯·.
Basics
git init β create a new repository
git clone
git status β check current changes
git add
git add . β add all files
git commit -m “msg” β commit changes
git log β full commit history
git log –oneline β short history view
git show
git diff β show unstaged changes
Branches
git branch β list all branches
git branch
git checkout
git checkout -b
git switch
git switch -c
git merge
git rebase
git branch -d
git branch -D
Remote Repositories
git remote -v β show all remotes
git remote add origin
git push origin
git push -u origin
git pull origin
git fetch β fetch changes without merging
git remote remove origin β remove a remote
git remote rename old new β rename a remote
git remote set-url origin
git push origin –delete
Managing Changes
git diff –staged β compare staged changes
git reset
git reset –hard
git reset –soft
git revert
git checkout –
git restore
git restore –staged
git commit –amend β edit last commit
git commit –amend -m “msg” β edit commit message
Stash
git stash β save changes temporarily
git stash list β list all stashes
git stash pop β restore last stash and delete it
git stash apply stash@{n} β apply specific stash
git stash drop stash@{n} β delete stash
git stash clear β delete all stashes
git stash save “msg” β save stash with message
git stash show β show stash changes
git stash branch
git stash show -p β show patch of stash
Cherry-pick & Tags
git cherry-pick
git cherry-pick -n
git cherry-pick –continue β continue after conflict
git cherry-pick –abort β stop cherry-pick
git tag
git tag -a
git push origin
git push origin –tags β push all tags
git tag -d
git push origin :refs/tags/
Logs and History
git log –graph –oneline –all β graph view
git log –stat β show changes in each commit
git log –pretty=oneline β compact view
git log –pretty=format:"%h - %an, %ar : %s" β custom log format
git shortlog -sn β contributors list
git reflog β complete action history
git blame
git annotate
git show-branch β show branch history
git whatchanged β show commits and changes
Advanced
git bisect start β start binary search for bug
git bisect bad β mark commit as bad
git bisect good β mark commit as good
git bisect reset β finish bisect
git clean -fd β delete untracked files
git clean -n β preview untracked delete
git submodule add
git submodule update –init β initialize submodules
git submodule foreach git pull β update submodules
git archive –format=zip HEAD > file.zip β export project
Collaboration & Workflow
git fetch –all β fetch all branches
git pull –rebase β pull with rebase
git push –force β force push
git push –force-with-lease β safe force push
git rebase -i HEAD~n β interactive rebase
git merge –squash
git rebase –abort β abort rebase
git rebase –continue β continue rebase
git merge –abort β abort merge
git cherry β show unmerged commits
Misc
git help
git config –list β show config
git config –global user.name “Name” β set username
git config –global user.email “Email” β set email
git config core.editor “code –wait” β set editor
git init –bare β create bare repo
git archive
git fsck β check integrity
git gc β clean up repository
gitk β open Git GUI
Key Points ^-^
100 commands cover 90% of daily and advanced Git usage
Donβt memorize, use this as a reference
Git is about save points, branches and history merging