Git Cheatsheet Pro
100+ essential commands. Searchable, categorized & copy-ready.
git initInitialize a new Git repository
git clone [url]Clone a repository into a new directory
git statusShow modified files in working directory
git add .Add all file changes to staging area
git add [file]Add specific file to staging area
git commit -m '[msg]'Commit all staged changes to local repo
git diffShow unstaged changes
git diff --stagedShow staged changes
git remote -vShow remote origins
git remote add origin [url]Add a remote repository
git branchList all local branches
git branch -aList all branches (local & remote)
git branch [name]Create a new branch
git checkout [branch]Switch to specified branch
git checkout -b [branch]Create a new branch and switch to it
git merge [branch]Merge specified branch into current branch
git branch -d [branch]Delete a local branch (safe)
git branch -D [branch]Force delete a local branch
git push origin --delete [branch]Delete a remote branch
git push origin [branch]Push local commits to remote repository
git push -u origin [branch]Push and set upstream branch
git push --forceForce push (overwrites remote)
git pullFetch and merge changes from remote
git pull --rebaseFetch and rebase instead of merge
git fetchDownload objects and refs from remote
git fetch --allFetch all remotes
git stashTemporarily store modified, tracked files
git stash save '[message]'Stash with a description
git stash listList all stashed changesets
git stash popRestore the most recently stashed files
git stash applyApply stash without removing it
git stash apply stash@{n}Apply a specific stash
git stash dropDelete the most recent stash
git stash clearDelete all stashes
git logShow commit history
git log --onelineShow commit history in single lines
git log --graphShow commit history with ASCII graph
git log --oneline --graph --allVisualize all branch history
git log -p [file]Show changes over time for specific file
git log --author='[name]'Show commits by specific author
git log --since='2 weeks ago'Show commits from last 2 weeks
git blame [file]Show who changed what and when in file
git show [commit]Show details of specific commit
git reflogShow a log of changes to HEAD
git checkout -- [file]Discard changes to a file
git restore [file]Restore file to last commit (Git 2.23+)
git reset [file]Unstage a file while retaining changes
git reset --soft HEAD~1Undo last commit, keep changes staged
git reset --mixed HEAD~1Undo last commit, keep changes unstaged
git reset --hard HEAD~1Undo last commit and delete changes
git reset --hard [commit]Reset to specific commit (destroys history)
git revert [commit]Create new commit that undoes changes
git clean -fdRemove untracked files and directories
git clean -fdnPreview what will be deleted
git tagList all tags
git tag [name]Create a lightweight tag
git tag -a [name] -m '[msg]'Create an annotated tag
git push origin [tagname]Push a tag to remote
git push origin --tagsPush all tags to remote
git tag -d [name]Delete a local tag
git push origin :refs/tags/[name]Delete a remote tag
git rebase [branch]Reapply commits on top of another base tip
git rebase -i HEAD~[n]Interactive rebase last n commits
git cherry-pick [commit]Apply changes from specific commit
git bisect startStart binary search for bad commit
git bisect badMark current commit as bad
git bisect good [commit]Mark commit as good
git bisect resetEnd bisect session
git worktree add [path] [branch]Create a linked working tree
git worktree listList all working trees
git worktree remove [path]Remove a working tree
git archive --format=zip HEAD > [file.zip]Create zip of repository
git config --global user.name '[name]'Set author name globally
git config --global user.email '[email]'Set author email globally
git config --listList all settings
git config --global alias.[alias] [command]Create command shortcut
git config --global core.editor '[editor]'Set default editor
git config --global color.ui autoEnable helpful colorization
git submodule add [url] [path]Add a submodule
git submodule initInitialize submodules
git submodule updateUpdate submodules
git submodule update --remoteUpdate submodules to latest commit
git submodule foreach git pull origin mainPull all submodules
git fsckVerify database integrity
git gcClean up unnecessary files and optimize repo
git pruneRemove unreachable objects
git remote prune originRemove stale remote branches
git reflog expire --expire=now --allClear reflog immediately
git ls-filesShow tracked files
git ls-files --othersShow untracked files
git flow initInitialize git flow
git flow feature start [name]Start a new feature branch
git flow feature finish [name]Finish a feature branch
git flow release start [version]Start a release branch
git flow release finish [version]Finish a release branch
git flow hotfix start [name]Start a hotfix branch
git flow hotfix finish [name]Finish a hotfix branch
Enjoying Git Command Cheat Sheet? 🚀
WebGati provides this tool for free. Help us keep it alive by sharing it with your network!
Need a Custom Tool like this for your Business?
I build high-performance web apps, AI tools, and SaaS platforms. Let's build your next big idea.
Start a Project