Cheatography
https://cheatography.com
This Git Cheatsheet is a quick reference guide to essential Git commands used in version control. It provides concise syntax and examples to help developers manage their code efficiently across local and remote repositories.
Setup & Configuration
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global core.editor "vim"
git config --global color.ui auto
git config --global alias.st status
git config --list
git config --get user.email
|
Initializing & Cloning Repos
git init
git init <directory>
git clone <url>
git clone --branch <branch> <url>
|
Stage & Commit Workflow
git status
git add <file>
git add . or git add --all
git commit -m "message"
git commit -a
git commit --amend
|
Viewing History & Differences
git log
git log --oneline --graph --all
git log --follow <file>
git log --author="Name"
git log --since="2 weeks ago"
git diff
git diff --staged or --cached
git diff HEAD
git diff <commit1> <commit2>
git show <commit>
git blame <file>
|
Branching & Merging
git branch
git branch -a
git branch -vv
git branch <name>
git branch -d <name>
git branch -r
git checkout <branch>
git checkout -b <new>
git checkout -- <file>
git merge <branch>
git rebase <branch>
git rebase -i HEAD~3
|
Remotes & Collaboration
git remote -v
git remote add origin <url>
git remote rename old new
git remote remove <name>
git fetch
git fetch --prune
git pull
git pull --rebase
git push origin <branch>
git push --all
git push --tags
|
Stashing Changes
git stash
git stash list
git stash apply
git stash pop
git stash drop
git stash clear
|
Undo, Reset & Restore
git checkout -- <file>
git restore <file>
git restore --staged <file>
git reset <file>
git reset --soft <commit>
git reset --mixed <commit>
git reset --hard <commit>
git revert <commit>
|
Tags & Releases
git tag
git tag <name>
git tag -a <name> -m "message"
git push origin <tag>
git push origin --tags
|
Cleaning & Maintenance
git clean -n
git clean -f
git clean -fd
git gc
git prune
git fsck
|
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets