Introduction: Whether you're a solo developer or collaborating with a team, version control is non-negotiable—and Git is the standard. It helps manage code changes, track history, experiment safely, and work across branches. But let’s be honest: Git's power can be overwhelming at first. That’s why I’ve compiled this concise, no-fluff Git cheatsheet to help you get up to speed quickly and stay productive.

🚀 Getting Started

🔧 Initialize a Repository

git init

Begin tracking a project in your current directory. This sets up a hidden .git folder.

📅 Clone an Existing Repo

git clone

Download a copy of a remote repository to your local machine.

📝 Tracking and Saving Changes

➕ Stage Files

git add 
git add .

Mark files to be included in the next commit.

✅ Commit Changes

git commit -m "your message"

Save a snapshot of staged changes with a message.

🔍 View Status

git status

Check what’s staged, modified, or untracked.

📊 View Differences

git diff        # unstaged vs working directory  
git diff --cached  # staged vs last commit

🌿 Branching & Merging

🌱 Create a Branch

git branch

📍 Switch Branches

git checkout 
git checkout -b

🔀 Merge Branches

git merge

☁️ Working with Remotes

📄 Push Changes

git push origin

📅 Pull Updates

git pull origin

📜 View History

git log

💠 Advanced Commands

⏪ Revert a Commit

git revert

Safely undo a commit without rewriting history.

🔀 Reset Commits

git reset --soft HEAD~1  
git reset --mixed HEAD~1  
git reset --hard HEAD~1

Control whether to keep, unstage, or discard changes when going back.

📦 Stash Your Work

git stash
git stash apply

Temporarily save your changes and come back to them later.

🍒 Cherry Pick Commits

git cherry-pick

Apply a specific commit from one branch onto another.

💪 Rebase Branches

git rebase

Reapply commits from one branch on top of another for a cleaner history.

⚙️ Productivity Boosters

⚓ Git Hooks

Automate tasks before/after Git events by placing scripts in .git/hooks.

⚡ Create Aliases

git config --global alias.co checkout
git config --global alias.br branch

📚 Popular Git Workflows

  • Centralized Workflow: Direct commits to main
  • Feature Branch Workflow: Isolated branches per feature
  • Gitflow: Structured with main, develop, release, and feature branches

🔗 Connect with me:

💼 LinkedIn

💻 GitHub