πŸ§‘β€πŸ’»πŸŒ³ Git Commands Cheat Sheet – Top 75 for Devs


πŸ“¦ 1–15: Repository Basics

  • πŸ“₯ git init – Initialize a new repo
  • πŸ“¦ git clone URL – Clone an existing repo
  • πŸ“„ git status – Show file status
  • πŸ“„ git add file – Stage file
  • πŸ“‚ git add . – Stage all changes
  • πŸ“Έ git commit -m “message” – Commit staged files
  • ♻️ git commit –amend – Amend last commit
  • πŸ“œ git log – View commit history
  • πŸ”’ git log –oneline – Compact log view
  • πŸ“€ git push – Push to remote
  • πŸ“₯ git pull – Pull latest changes
  • πŸ”€ git fetch – Download changes (no merge)
  • 🌍 git remote -v – View remote URLs
  • βž• git remote add origin URL – Add a remote
  • ❌ git remote remove origin – Remove remote

🌿 16–30: Branching & Merging

  • 🌱 git branch – List branches
  • 🌿 git branch new-branch – Create new branch
  • πŸš€ git checkout branch – Switch branches
  • 🌳 git checkout -b new-branch – Create & switch branch
  • πŸ”€ git merge branch – Merge into current
  • ❌ git branch -d branch – Delete branch (safe)
  • πŸ’£ git branch -D branch – Force delete branch
  • 🧾 git log –graph –all – Branch history
  • πŸ” git show branch – Show branch commit
  • πŸ“€ git push origin branch – Push specific branch
  • πŸ“₯ git pull origin branch – Pull specific branch
  • 🎯 git checkout –track origin/branch – Track remote branch
  • πŸ”„ git rebase branch – Reapply commits
  • 🧹 git stash – Save uncommitted changes
  • πŸ“₯ git stash pop – Restore last stash

πŸ› οΈ 31–45: File & Commit Operations

  • πŸ” git diff – Compare changes
  • πŸ” git diff –staged – Compare staged changes
  • ❌ git reset file – Unstage a file
  • πŸ”„ git restore file – Undo local file changes
  • 🧹 git clean -f – Remove untracked files
  • 🧹 git clean -fd – Remove untracked dirs/files
  • πŸ”„ git reset –soft HEAD~1 – Undo last commit (keep changes)
  • πŸ’£ git reset –hard HEAD~1 – Undo commit & changes
  • 🧾 git revert commit – Revert a commit (new commit)
  • πŸ“‹ git blame file – Who changed each line
  • πŸ“₯ git checkout commit file – Restore file from commit
  • πŸ” git show commit – View commit details
  • πŸ“¦ git cherry-pick commit – Apply commit on current branch
  • πŸ“œ git log -p – View patch differences
  • πŸ“ˆ git shortlog – Summarized contributors list

🌐 46–60: Working with Remotes

  • πŸ“ git remote – List remotes
  • πŸ“€ git push origin main – Push to main branch
  • πŸš€ git push -u origin branch – Push & set upstream
  • πŸ“₯ git pull origin main – Pull from main
  • 🧭 git remote show origin – Details of remote
  • πŸ”„ git fetch origin – Download from remote
  • πŸ§ͺ git ls-remote – List refs in remote
  • ⚠️ git push –force – Force push (use with caution!)
  • πŸ” git push –tags – Push tags to remote
  • πŸ”€ git pull –rebase – Rebase instead of merge
  • πŸ“€ git push origin –delete branch – Delete remote branch
  • πŸ“ git remote rename old new – Rename remote
  • 🧹 git remote prune origin – Remove deleted remote branches
  • πŸ“„ git config –list – Show config
  • πŸ“ git config –global user.name “Name” – Set user name

🏷️ 61–75: Tags, Logs & Tools

  • 🏷️ git tag – List tags
  • βž• git tag v1.0 – Create lightweight tag
  • πŸ“ git tag -a v1.0 -m “desc” – Annotated tag
  • πŸ“€ git push origin v1.0 – Push tag to remote
  • ❌ git tag -d v1.0 – Delete local tag
  • 🧼 git gc – Cleanup unnecessary files
  • 🧾 git reflog – History of HEAD changes
  • 🧠 git config alias.co checkout – Create alias
  • 🧰 git archive – Export as zip/tar
  • πŸ“… git log –since=”2 weeks ago” – Time-filtered log
  • πŸ“œ git show HEAD – View last commit
  • πŸ“Š git count-objects -v – Count git objects
  • πŸ—ƒοΈ git bundle – Bundle for offline transfer
  • πŸ’¬ git notes add -m “note” – Add commit note
  • πŸ›‘οΈ git fsck – Integrity check

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top