Basic Commands
git init

Initialize a new Git repository

git clone <url>

Clone a repository

git status

Check status of working directory

git add <file>

Stage a file

git add .

Stage all changes

git commit -m "message"

Commit staged changes

git log

View commit history

git diff

Show changes

Branching
git branch

List branches

git branch <name>

Create a new branch

git checkout <branch>

Switch to branch

git checkout -b <branch>

Create and switch to branch

git merge <branch>

Merge branch into current

git branch -d <branch>

Delete branch

Remote
git remote -v

List remotes

git remote add <name> <url>

Add remote

git push <remote> <branch>

Push to remote

git pull <remote> <branch>

Pull from remote

git fetch

Fetch from remote

Undo
git reset HEAD <file>

Unstage file

git checkout -- <file>

Discard changes

git revert <commit>

Revert a commit

git reset --soft HEAD~1

Undo last commit, keep changes

git reset --hard HEAD~1

Undo last commit, discard changes