Git cheatsheet

Quick reference for Git commands and workflows

Git Cheatsheet

Common Git commands with descriptions

All
Configuration
Repository
Basic
Branching
Remote
History
Undoing
Stashing
Tags

Configuration

git config --global user.name "Name"
git config --global user.email "email"
git config --list

Repository

git init
git clone <url>
git status

Basic

git add .
git add <file>
git commit -m "message"
git commit --amend
git diff
git diff --staged

Branching

git branch
git branch <name>
git checkout <branch>
git checkout -b <name>
git merge <branch>
git rebase <branch>
git branch -d <name>

Remote

git remote -v
git remote add origin <url>
git fetch origin
git pull origin <branch>
git push origin <branch>
git push -u origin <branch>

History

git log
git log --oneline
git log --graph --oneline
git blame <file>

Undoing

git reset HEAD <file>
git checkout -- <file>
git revert <commit>
git reset --hard HEAD~1

Stashing

git stash
git stash pop
git stash list
git stash drop

Tags

git tag <name>
git tag -a <name> -m "msg"
git push origin --tags