git

Git Cheatsheet

Init & Config

git init
git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Staging & Commit

git add .
git commit -m "message"
git status
git log

Branching

git branch
git checkout -b new-branch
git merge new-branch
git branch -d new-branch

Remote

git remote add origin https://github.com/user/repo.git
git push -u origin main
git pull origin main
git clone https://github.com/user/repo.git

Reset & Revert

git reset --soft HEAD~1
git reset --hard HEAD~1
git reset HEAD filename
git checkout -- filename
git revert <commit-hash>

Stash

git stash
git stash list
git stash apply

Rebase

git rebase branch-name
git rebase -i HEAD~3
git rebase --abort
← Back to Cheatsheet