Bizmotix Icon
Git Cheat Sheet

Your Fast, Practical Git Companion

A curated list of the most useful Git commands for everyday work—clear descriptions and copy-ready snippets.

Basics
Basics Commands
Initialize a repo
Start a new repository in the current folder.
git init
# or
git init --initial-branch=main
Clone a repo
Download a remote repository.
git clone  [folder]
Status
See changes staged, unstaged, and untracked.
git status
Stage changes
Move changes to the index before commit.
git add 
# stage all
git add -A
Commit
Record a snapshot with a message.
git commit -m "feat: message"
# amend last commit message
git commit --amend -m "new message"
Log
Compact history view.
git log --oneline --graph --decorate --all
Config
Config Commands
Set author
Identify yourself for commits.
git config --global user.name "Your Name"
git config --global user.email you@example.com
Branching
Branching Commands
List branches
Show local and remote branches.
git branch --all
Create/switch
Create and move to a new branch.
git switch -c feature/x
# or
git checkout -b feature/x
Rename
Rename current branch.
git branch -m old-name new-name
Delete
Delete a local branch.
git branch -d feature/x
# force
git branch -D feature/x
Remote
Remote Commands
Add remote
Link to a remote repository.
git remote add origin 
Push & set upstream
Push and track remote branch.
git push -u origin main
Pull
Update your branch; prefer rebase to avoid merge commits.
git pull --rebase
Fetch
Update remote refs without merging.
git fetch --all --prune
Merge & Rebase
Merge & Rebase Commands
Merge
Combine histories with a merge commit (non-linear).
git switch main
git merge feature/x
Rebase
Replay commits onto another base (linear history).
git switch feature/x
git rebase main
Resolve rebase
Continue after resolving conflicts.
# fix conflicts, then
git add -A
git rebase --continue
Abort rebase
Stop and restore previous state.
git rebase --abort
Stash
Stash Commands
Stash changes
Put work aside without committing.
git stash push -m 'wip: message'
# include untracked
git stash push -u -m 'wip'
List & apply
Inspect and re-apply a stash.
git stash list
git stash show -p stash@{0}
git stash apply stash@{0}
Pop
Apply and remove from stash stack.
git stash pop
Undo & Fix
Undo & Fix Commands
Discard file changes
Revert changes in working tree and index.
git restore 
# all
git restore --source=HEAD --staged --worktree .
Reset (soft/mixed/hard)
Travel back N commits; choose impact level.
# move HEAD only
git reset --soft HEAD~1
# unstage files
git reset --mixed HEAD~1
# discard changes
git reset --hard HEAD~1
Revert commit
Create a new commit that undoes another.
git revert 
# without editor
git revert --no-edit 
Reflog (time machine)
See where HEAD pointed; recover lost work.
git reflog
# recover lost branch
git switch -c rescue 
Inspect
Inspect Commands
Diff
See what changed.
git diff
# staged vs HEAD
git diff --cached
Blame
Who changed what, and when.
git blame  -L 10,40
Show commit
Display objects and diffs.
git show 
# show file from commit
git show :path/to/file
Tags & Releases
Tags & Releases Commands
Create tag
Mark a specific point.
git tag v1.0.0
# annotated
git tag -a v1.0.0 -m 'release: 1.0.0'
Push tags
Upload all tags to remote.
git push --tags
Advanced
Advanced Commands
Cherry-pick
Copy a specific commit onto current branch.
git cherry-pick 
# keep original author
git cherry-pick -x 
Squash commits
Combine multiple commits into one.
git rebase -i HEAD~5
# mark some as 's' to squash
Tip:Prefer git add -A over git add . and use --force-with-lease instead of --force.
Keep exploring: git help <verb>, man git-<verb>, or the Pro Git book.
Your Fast, Practical Git Companion