The Git commands you reach for daily — staging, branching, syncing and undoing. Tap any command to copy it.
git initCreate a new Git repository in the current foldergit clone <url>Copy a remote repository to your machinegit config --global user.name "Name"Set the name attached to your commitsgit config --global user.email "you@example.com"Set the email attached to your commitsgit statusShow changed, staged and untracked filesgit add <file>Stage a specific file for the next commitgit add .Stage all changes in the current foldergit commit -m "message"Commit staged changes with a messagegit commit -am "message"Stage tracked files and commit in one stepgit restore <file>Discard uncommitted changes to a filegit reset <file>Unstage a file but keep its changesgit branchList local branchesgit switch -c <name>Create a new branch and switch to itgit switch <name>Switch to an existing branchgit merge <name>Merge another branch into the current onegit branch -d <name>Delete a merged branchgit rebase <name>Reapply commits on top of another branchgit remote -vShow configured remote repositoriesgit remote add origin <url>Connect a local repo to a remotegit pushUpload commits to the remotegit push -u origin <branch>Push and set the upstream branchgit pullFetch and merge changes from the remotegit fetchDownload remote changes without merginggit log --onelineShow a compact commit historygit diffShow unstaged changes line by linegit stashShelve uncommitted changes for latergit stash popReapply the most recently stashed changesgit revert <commit>Create a new commit that undoes a commitgit reset --hard <commit>Reset the branch and working tree to a commitgit cherry-pick <commit>Apply a specific commit onto the current branchMost Git work comes down to a handful of commands: git status, git add, git commit, and git push. This cheatsheet groups those with the branching, syncing and undo commands you reach for less often but always forget — like git stash, git revert and git rebase. Click any command to copy it.