Git Cheatsheet

Search, filter, and instantly copy essential Git commands, branch operations, and remote repository configurations.

Set global git usernameInitial Setup
git config --global user.name "Your Name"
Set global git email addressInitial Setup
git config --global user.email "email@example.com"
Initialize a new local Git repositoryRepo Creation
git init
Clone a remote repository to local machineRepo Creation
git clone <repo-url>
Show status of files in working directoryInspection
git status
Add a specific file to staging areaStaging
git add <file>
Add all modified and new files to staging areaStaging
git add .
Record staged files to commit historyCommit
git commit -m "Commit message"
Overwrite the latest local commitModify Commit
git commit --amend -m "New message"
Display commit history in single linesInspection
git log --oneline
List local branchesBranching
git branch
Create a new branch and switch to itBranching
git checkout -b <branch-name>
Switch to an existing branchNavigation
git checkout <branch-name>
Merge specified branch into active branchMerging
git merge <branch-name>
Delete a merged local branchCleanup
git branch -d <branch-name>
Link local repo to a remote endpointRemote setup
git remote add origin <url>
Upload local commits to remote branchUpload
git push origin <branch-name>
Fetch and merge remote changes to localDownload
git pull origin <branch-name>
Download remote changes without mergingInspection
git fetch origin
Temporarily shelve uncommitted active changesStashing
git stash
Restore the most recently stashed changesStashing
git stash pop
Undo last commit and delete changesCAUTION: Destructive
git reset --hard HEAD~1
Undo last commit but keep files stagedSafety Reset
git reset --soft HEAD~1
Discard changes in a local fileSafety Reset
git checkout -- <file-name>

Frequently Asked Questions

What is Git?
Git is a distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
How do I copy commands?
Simply click the copy button next to any command block to put it directly onto your clipboard.