Git/Github Cheat Sheet
by Muhammad Usman Asghar (musmankkh) via [Link]/214866/cs/46788/
Setup & Configuration
git config --global [Link] "Your Name"
git config --global [Link] "you@example.com"
git config --global core.editor "vim"
git config --global [Link] auto
git config --global [Link] status
git config --list
git config --get [Link]
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>
By Muhammad Usman Published 25th July, 2025. Sponsored by [Link]
Asghar (musmankkh) Last updated 25th July, 2025. Everyone has a novel in them. Finish
Page 1 of 3. Yours!
[Link]
[Link]/musmankkh/
Git/Github Cheat Sheet
by Muhammad Usman Asghar (musmankkh) via [Link]/214866/cs/46788/
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
By Muhammad Usman Published 25th July, 2025. Sponsored by [Link]
Asghar (musmankkh) Last updated 25th July, 2025. Everyone has a novel in them. Finish
Page 2 of 3. Yours!
[Link]
[Link]/musmankkh/
Git/Github Cheat Sheet
by Muhammad Usman Asghar (musmankkh) via [Link]/214866/cs/46788/
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
By Muhammad Usman Published 25th July, 2025. Sponsored by [Link]
Asghar (musmankkh) Last updated 25th July, 2025. Everyone has a novel in them. Finish
Page 3 of 3. Yours!
[Link]
[Link]/musmankkh/