Git Skills
Setup & Config
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
git config --global core.editor vim
git config --list
Basic Commands
Status & Logs
git status
git status -s
git log
git log --oneline
git log -n 5
git log --graph
Add & Commit
git add file.txt
git add .
git add -p
git commit -m "message"
git commit -am "message"
git commit --amend
Branching
git branch
git branch feature/login
git checkout feature/login
git switch -c feature/login
git branch -d feature/login
git branch -m new-name
Merging
git checkout main
git merge feature/login
git merge --no-ff feature
git merge --squash feature
Rebasing
git rebase main
git rebase -i HEAD~3
git rebase --continue
git rebase --abort
Remote Operations
Push & Pull
git push origin main
git push -u origin feature
git push --force
git pull
git pull --rebase
git fetch
Remote Management
git remote -v
git remote add origin url
git remote remove origin
git remote rename origin upstream
Advanced Operations
Stashing
git stash
git stash pop
git stash apply
git stash list
git stash drop
git stash -u
Resetting
git reset HEAD~1
git reset --soft HEAD~1
git reset --hard HEAD~1
Cherry Picking
git cherry-pick abc123
git cherry-pick abc123 def456
Tagging
git tag v1.0.0
git tag -a v1.0.0 -m "Release 1.0"
git push origin v1.0.0
git tag -d v1.0.0
Workflow Examples
Feature Branch Workflow
git checkout -b feature/new-feature
git add .
git commit -m "Add new feature"
git push -u origin feature/new-feature
git checkout main
git pull origin main
git branch -d feature/new-feature
Hotfix Workflow
git checkout main
git pull
git checkout -b hotfix/bug-fix
git commit -am "Fix critical bug"
git checkout main
git merge --no-ff hotfix/bug-fix
git push origin main
git branch -d hotfix/bug-fix
Finding & Fixing Issues
Blame & Show
git blame file.txt
git show abc123
git show abc123:file.txt
Bisect (Find Bug)
git bisect start
git bisect bad HEAD
git bisect good abc123
git bisect good
git bisect reset
Diff
git diff
git diff --staged
git diff HEAD~1
git diff main...feature