Git command cheatsheet covering init, commit, branch, merge, remote, and undo operations with search and filter support. Great for Git beginners and daily reference. Available on ToolNext — the free online toolbox.
git initInitialize a new repository in current directorygit init <directory>Initialize repository in specified directorygit config --global user.name "Name"Set global usernamegit config --global user.email "email"Set global emailgit config --listList all config settingsgit clone <url>Clone a remote repositorygit clone <url> <directory>Clone into specified directorygit statusShow working tree statusgit add <file>Stage a specific filegit add .Stage all changesgit add -pInteractively stage changesgit commit -m "message"Commit staged changesgit commit --amendModify the last commitgit commit --amend --no-editAmend commit without changing messagegit rm <file>Remove file and stage deletiongit mv <old> <new>Move or rename a filegit branchList local branchesgit branch <name>Create a new branchgit branch -d <name>Delete branch (merged)git branch -D <name>Force delete a branchgit branch -rList remote branchesgit checkout -b <name>Create and switch to new branchgit switch <name>Switch to specified branchgit switch -c <name>Create and switch to branchgit merge <branch>Merge specified branch into currentgit merge --no-ff <branch>No-fast-forward merge (preserve history)git rebase <branch>Rebase current branch onto specified branchgit rebase -i HEAD~nInteractive rebase (squash/edit commits)git remote add origin <url>Add a remote repositorygit remote -vView remote repository detailsgit remote remove <name>Remove a remote repositorygit pushPush to remote repositorygit push -u origin <branch>Push and set upstream branchgit push --force-with-leaseSafe force pushgit pullPull and merge remote changesgit pull --rebasePull and rebasegit fetchFetch remote changes (no merge)git fetch --allFetch all remote changesgit logView commit historygit log --onelineOne-line commit historygit log --graph --onelineGraphical branch historygit log -pShow diff for each commitgit log --author="name"Filter history by authorgit diffView unstaged changesgit diff --stagedView staged changesgit diff <branch1>..<branch2>Compare two branchesgit show <commit>View details of a specific commitgit blame <file>View line-by-line edit historygit reset HEAD <file>Unstage a specific filegit reset --soft HEAD~1Undo last commit (keep changes)git reset --hard HEAD~1Undo last commit (discard changes)git revert <commit>Create a revert commitgit checkout -- <file>Discard working directory changesgit restore <file>Restore file (new syntax)git stashStash current working changesgit stash popApply the latest stashgit stash listList all stashesgit stash dropDrop the latest stashgit clean -fdRemove untracked files and directoriesgit tagList all tagsgit tag <name>Create a lightweight taggit tag -a <name> -m "msg"Create an annotated taggit tag -d <name>Delete a local taggit push --tagsPush all tags to remotegit push origin :refs/tags/<name>Delete a remote taggit cherry-pick <commit>Apply a specific commit to current branchgit bisect startStart binary search for a buggit bisect good/badMark current commit as good/badgit archive --format=zip HEAD > out.zipExport repository as zipgit submodule add <url>Add a submodulegit submodule update --initInitialize and update submodulesgit worktree add <path> <branch>Create a new worktreegit reflogView reflog (recover lost commits)