DEV Community

Cover image for for when i forget how to use GIT Quick Setup & Commands Cheat Sheet (Linux, Mac & Windows)
قاسم الشيخ علي
قاسم الشيخ علي

Posted on

for when i forget how to use GIT Quick Setup & Commands Cheat Sheet (Linux, Mac & Windows)

Raise your hand if you’ve ever stared at your terminal, completely blanking on basic Git commands. 😅

Whether you’re switching devices, reinstalling your OS, or just need a refresher, forgetting Git workflows is painfully relatable. After many frantic Google searches, I’ve compiled a survival guide for setting up Git and jogging your memory—complete with cross-platform tips and cheat sheets.


  1. "Wait, How Do I Install Git Again?"

Linux (Debian/Ubuntu):

sudo apt update && sudo apt install git -y  
Enter fullscreen mode Exit fullscreen mode

Linux (Fedora):

sudo dnf install git  
Enter fullscreen mode Exit fullscreen mode

Mac:

  • Via Homebrew (recommended):
  brew install git  
Enter fullscreen mode Exit fullscreen mode
  • Or use Xcode CLI Tools:
  xcode-select --install  
Enter fullscreen mode Exit fullscreen mode

Windows:

  1. Download the official installer: git-scm.com
  2. Run the .exe and follow prompts (check "Git Bash" for terminal access).

  1. "I Forgot How to Configure Git!" Set your identity (do this once per machine):
git config --global user.name "Your Name"  
git config --global user.email "your@email.com"  
Enter fullscreen mode Exit fullscreen mode

💡 Pro Tip: Use --global for system-wide settings or --local per-project.


  1. "What’s the Command for…?" – Cheat Sheet
    Scenario Command
    Start a new repo git init
    Clone a repo git clone https://github.com/user/repo.git
    Check status git status
    Stage all changes git add . (or git add filename)
    Commit changes git commit -m "Your message here"
    Push to remote git push origin main (or branch name)
    Pull latest changes git pull
    Create a new branch git checkout -b new-branch-name
    Switch branches git checkout branch-name
    Merge branches git merge branch-name
    View commit history git log --oneline --graph
    Undo local changes git restore filename (or git checkout -- filename)
    Stash changes temporarily git stash (pop with git stash apply)

  1. "Help! I Still Forget Things!" – Lifeline Resources 📌 Bookmark these for quick access!

  1. Pro Tips to Avoid Future Panic
    • Alias Commands: Shorten frequent commands in ~/.gitconfig:
  [alias]  
    st = status  
    cm = commit -m  
    co = checkout  
Enter fullscreen mode Exit fullscreen mode
  • Use a GUI: Tools like GitKraken or VS Code’s built-in Git UI.
  • Practice Daily: Repetition is key! Try small projects to reinforce muscle memory.

Final Note:

Forgetting Git is normal—don’t let impostor syndrome win. Bookmark this post, keep those cheat sheets handy, and embrace the command-line chaos. 💻✨

What’s your go-to Git lifesaver? Share below! 👇


(Featured image idea: A chaotic desk with a laptop, coffee, and a sticky note saying "git push --force? 😬")


AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay