If you're new to Git, you've probably seen a command like this:
git checkout -b feature/login
…and thought:
“Okay… but what exactly am I supposed to remember?”
Git has a lot of commands.
The good news?
You don't need to memorize all of them.
For everyday development there's a small set of commands you'll use again and again.
So instead of throwing 50+ commands at you here's a practical Git cheat sheet for beginners that you can bookmark and come back to whenever Git decides to confuse you.
⚡ The Quick Git Cheat Sheet
Before getting into the details, here's the short version:
| I want to... | Command |
|---|---|
| Set my Git name | git config |
| Start Git in a project | git init |
| Download a repository | git clone |
| See what's changed | git status |
| Review my changes | git diff |
| Stage changes | git add |
| Save a checkpoint | git commit |
| View commit history | git log |
| Create a branch | git branch |
| Switch branches | git switch |
| Merge a branch | git merge |
| Upload commits | git push |
| Get remote changes | git pull |
| Check remote changes without integrating | git fetch |
| Temporarily save changes | git stash |
| Safely undo a commit | git revert |
You don't need to memorize this table.
*Bookmark it. That's literally what it's here for. *
1. Configure Git
Before using Git, tell it who you are.
• Set Your Name
git config --global user.name "Your Name"
Tells Git which name to associate with your commits.
• Set Your Email
git config --global user.email "you@example.com"
Sets the email associated with your commits.
• Check Your Configuration
git config --list
Useful when you want to verify your Git settings.
Think of this as telling Git:
“Hey, these commits belong to me.”
2. Start Working With a Repository
There are two common ways to start working with Git.
• Create a New Repository
git init
Initializes Git inside your current project folder.
Use this when you already have a project on your computer and want Git to start tracking it.
• Clone an Existing Repository
git clone <repo_url>
Downloads an existing repository to your computer.
Use this when a project already exists on a remote platform such as GitHub and you want a local copy.
• Easy way to remember:
git init → start Git here
git clone → bring an existing repository here
3. Track and Save Your Changes
This is where you'll probably spend most of your time.
Imagine this:
You changed three files and now have absolutely no idea what Git thinks happened.
Start with:
• Check What Changed
git status
Shows modified, staged and untracked files.
When you're confused about what's happening in your repository:
Run git status.
Seriously.
• Review Your Changes
git diff
Shows changes that haven't been staged yet.
It's useful when you want to review your work before staging it.
Think:
“What exactly did I change?”
→ git diff
• Stage a Specific File
git add <file>
Example:
git add index.html
This tells Git:
“Include this file's changes in my next commit.”
• Stage Everything
git add .
Stages changes under the current directory and its subdirectories.
It's convenient when you're sure you want to include those changes.
Still, it's a good habit to check:
git status
before committing.
If you only want to stage a specific file:
git add <file>
• Create a Commit
git commit -m "Add login form"
A commit is basically a checkpoint for your project.
Instead of:
git commit -m "changes"
prefer something descriptive:
git commit -m "Fix navbar responsiveness"
Good commit messages make your project history much easier to understand.
Think:
Commit = save a checkpoint of your staged changes.
• See Your Commit History
git log
Shows previous commits along with information such as the author, date and commit message.
Want a shorter version?
git log --oneline
This gives you a compact view of your commit history.
4. Work With Branches
Branches let you work on features, experiments or fixes separately from your main branch.
For example:
main
│
├── feature/navbar
├── feature/login
└── fix/mobile-layout
Instead of experimenting directly on main, you can create a separate branch for your work.
• See Your Branches
git branch
Lists your local branches.
• Create a Branch
git branch <name>
Example:
git branch feature/navbar
Creates a new branch but does not switch you to it.
• Switch Branches
Modern Git provides git switch specifically for changing branches:
git switch <branch>
Example:
git switch feature/navbar
You may also see this older, still-common command:
git checkout feature/navbar
You don't necessarily need to use checkout for everyday branch switching but you should recognize it because you'll encounter it in older tutorials and projects.
• Create and Switch to a Branch
With modern Git:
git switch -c <branch>
Example:
git switch -c feature/navbar
This does two things:
Create branch → Switch to branch
You may also see:
git checkout -b feature/navbar
Both patterns are worth recognizing.
• Merge a Branch
Suppose you're currently on main and want to bring changes from feature/navbar into it:
git merge feature/navbar
Git combines the changes from the specified branch into your current branch.
The important part:
Git merges into the branch you're currently on.
So if you're on main:
git merge feature/navbar
means:
“Bring feature/navbar into main.”
5. Work With Remote Repositories
Your local Git repository and a remote repository such as GitHub are separate.
These commands help you synchronize them.
• See Connected Remotes
git remote -v
Shows the remote repositories connected to your project.
• Add a Remote
git remote add origin <url>
origin is simply the conventional name for the remote repository.
• Push Your Commits
git push origin <branch>
Example:
git push origin main
Uploads your local commits to the remote repository.
Think:
push → send my commits to the remote
• Pull Remote Changes
git pull
Gets changes from the remote repository and integrates them into your current branch.
Depending on your Git configuration that integration may involve merging or rebasing.
For beginners, remember:
pull → get remote changes + integrate them
• Fetch Remote Changes
git fetch
Downloads information about remote changes without automatically integrating them into your current branch.
A simple way to remember the difference:
fetch = get the information
pull = get + integrate
6. Undo and Manage Changes
This is where Git can start feeling a little scary.
But you don't need to memorize every recovery command.
Here are some common situations.
• Unstage a File
If you've staged a file but want to remove it from the staging area while keeping your changes:
git restore --staged <file>
Example:
git restore --staged index.html
Think:
“Keep my changes, but take this file out of staging.”
You may also see:
git reset <file>
in older tutorials and workflows.
• Safely Undo a Commit
git revert <commit_id>
Creates a new commit that reverses the changes introduced by an earlier commit.
This is useful when you want to undo a committed change while keeping the existing history intact.
• Temporarily Save Your Changes
git stash
Imagine you're working on something unfinished and suddenly need to switch branches.
You don't want to commit the unfinished work.
That's where stash can help.
git stash
Temporarily stores your local changes.
• Bring Stashed Changes Back
git stash pop
Restores the most recently stashed changes and removes that stash entry if the changes are applied successfully.
Easy way to remember:
stash → put it away
stash pop → bring it back
• Remove a File
git rm <file>
Removes the file and stages that removal.
Example:
git rm old-file.js
• Rename or Move a File
git mv <old> <new>
Example:
git mv old.js new.js
Renames or moves a file while letting Git track the change.
7. The Git Workflow You'll Actually Use
For many everyday tasks, the workflow looks like this:
Make changes
↓
git status
↓
git diff
↓
git add .
↓
git commit -m "Describe your changes"
↓
git push
Think of it as:
Change → Check → Review → Stage → Commit → Push
That's the basic rhythm you'll repeat constantly while working with Git.
Once you understand this flow, individual commands become much easier to remember.
8. What to Remember First
If you're completely new to Git, don't try to memorize everything at once.
Start with these:
git status
git diff
git add
git commit
git log
git switch
git pull
git push
Then gradually add:
git init
git clone
git branch
git merge
git fetch
git stash
git revert
git restore
You don't need to know Git perfectly before using Git.
Use the commands. Understand what they do. Look them up when you forget.
Eventually, they become second nature.
And when you forget one?
That's what cheat sheets are for.
Bookmark This
Git isn't about memorizing hundreds of commands.
It's about understanding the workflow:
Change
↓
Check
↓
Review
↓
Stage
↓
Commit
↓
Push
Once that workflow makes sense, Git becomes much less intimidating.
You don't need to remember every command today.
You just need to know what you're trying to do and which command helps you do it.
And yes...
you'll probably still Google git stash six months from now.
Save this for the next time Git decides to humble you.
And tell me:
Which Git command took you the longest to understand? 👇
Top comments (0)