Advertisement
← All Cheat Sheets

Git Commands Cheat Sheet

Essential Git commands for everyday use

Setup & Config

git config --global user.name "[name]"Set user name
git config --global user.email "[email]"Set user email
git initInitialize new git repo

Snapshots & Staging

git statusCurrent repo status
git add [file]Stage a file
git commit -m 'msg'Commit with message

Branches & Merging

git branchList branches
git checkout -b [branch]Create & switch branch
git merge [branch]Merge to current branch
git branch -d [branch]Delete branch

Remote

git clone [url]Clone repo
git remote -vShow remotes
git push origin [branch]Push to remote
git pullPull latest

Undo & Clean

git reset --hardReset to HEAD
git revert [commit]Revert commit
git clean -fdRemove untracked
Advertisement