Logo

Git Cheatsheet

My personal, go-to set of Git commands I use daily. Perfect for when you need a quick reference or just getting started!

Getting Started

git init

Start a new git repository in the current folder

git clone <url>

Copy an existing repository

git status

See what's changed and what's staged

git config --global user.name "Your Name"

Set your name for commits

Everyday Workflow

git add <file>

Stage a file for commit

git add .

Stage everything in the folder

git commit -m "Message"

Commit your staged changes with a neat message

git push

Send your commits to the remote repository

git pull

Get the latest changes from remote

Branching & Merging

git branch

List all branches

git checkout -b <branch>

Create and switch to a new branch

git checkout <branch>

Switch to an existing branch

git merge <branch>

Merge another branch into your current branch

Undo & Fix Mistakes

git restore <file>

Reset file changes (not staged)

git reset --hard

Discard all local changes (dangerous!)

git revert <commit>

Create a new commit that undoes the changes

Extras

git log --oneline --graph --decorate

Visualize commit history neatly

git stash

Temporarily save your changes to work on something else

git remote -v

See remote repository URLs

I keep coming back to these commands during development. If you're ever lost, run git status — it's your best friend!