Git Cheatsheet

Common git commands for daily use
A corgi smiling happily
git branchList all local branches.
git branch -aList remote and local branches.
git checkout -b branch_nameCreate a local branch and switch to it.
git checkout branch_nameSwitch to an existing branch.
git push origin branch_namePush branch to remote.
git branch -m new_nameRename current branch.
git branch -d branch_nameDelete a local branch.
git push origin :branch_nameDelete a remote branch.
git log --onelineShow commit history in single lines.
git log -2Show commit history for last N commits.
git log -p -2Show commit history for last N commits with diff.
git diffShow all local file changes in the working tree.
git diff myfileShow changes made to a file.
git blame myfileShow who changed what & when in a file.
git remote show originShow remote branches and their mapping to local.
git clean -fDelete all untracked files.
git clean -dfDelete all untracked files and directories.
git checkout -- .Undo local modifications to all files.
git reset HEAD myfileUnstage a file.
git pull --tagsGet remote tags.
git checkout tag_nameSwitch to an existing tag.
git tagList all tags.
git tag -a tag_name -m "tag message"Create a new tag.
git push --tagsPush all tags to remote repo.
git stash save "stash name" && git stashSave changes to a stash.
git stash listList all stashes.
git stash popApply a stash and delete it from stash list.


Do you have any questions, or simply wish to contact me privately? Don't hesitate to shoot me a DM on Twitter.

Have a wonderful day.
Abhishek 🙏

Subscribe to my newsletter

Get email from me about my ideas, full-stack development resources, tricks and tips as well as exclusive previews of upcoming articles.

No spam. Just the highest quality ideas you’ll find on the web.