Common GIT Cheat Sheet for Programmer

🚀 Git Cheatsheet

⚙️ Setup & Config
git config --global user.name "name"
Set your name
git config --global user.email "email"
Set your email
git init
Initialize a new repository
📝 Basic Commands
git status
Check repository status
git add <file>
Stage specific file
git add .
Stage all changes
git commit -m "message"
Commit staged changes
🌿 Branching
git branch
List all branches
git branch <name>
Create new branch
git checkout <branch>
Switch to branch
git checkout -b <branch>
Create and switch to new branch
git merge <branch>
Merge branch into current
🌐 Remote Repositories
git clone <url>
Clone a repository
git remote add origin <url>
Add remote repository
git push origin <branch>
Push to remote
git pull
Fetch and merge changes
git fetch
Download remote changes
🔍 Inspect & Compare
git log
View commit history
git log --oneline
Compact commit history
git diff
Show unstaged changes
git show <commit>
Show commit details
⚡ Undo & Advanced
git reset <file>
Unstage file
git reset --hard
Discard all changes
git revert <commit>
Revert a commit
git stash
Save changes temporarily
git stash pop
Apply stashed changes