🔧 Git Commands Reference

🚀 Init & Clone

git init                        # Initialize new repo
git clone <url>                # Clone remote repo
git clone -b branch <url>      # Clone specific branch

📦 Stage & Commit

git status                     # Check status
git add file.txt              # Stage file
git add .                     # Stage all changes
git commit -m "message"       # Commit changes
git commit -am "msg"          # Add and commit tracked files

🌿 Branching

git branch                     # List branches
git branch new-feature        # Create branch
git checkout new-feature      # Switch branch
git checkout -b new-feature   # Create and switch
git merge main                # Merge into current

# Delete branches
git branch -d feature         # Delete local
git push origin --delete feature  # Delete remote

🌍 Remote

git remote -v                 # View remotes
git remote add origin <url>  # Add remote
git push -u origin main      # Push to origin

git pull                     # Pull latest changes
git fetch                    # Fetch from remote
git push origin feature      # Push branch

🧳 Stash

git stash                     # Stash changes
git stash pop                 # Apply and drop stash
git stash list                # List stashes
git stash apply stash@{0}     # Apply specific

⏪ Undo, Reset, Revert

git checkout -- file          # Discard changes
git reset HEAD file           # Unstage file
git reset --soft HEAD~1       # Keep changes
git reset --hard HEAD~1       # Remove commit

git revert COMMIT             # Undo with commit

📜 Log, Diff & Blame

git log                       # Show commit logs
git log --oneline             # One-line logs
git diff                      # Show unstaged diff
git diff --staged             # Staged diff
git blame file.txt            # Who changed each line

🏷️ Tags

git tag                       # List tags
git tag v1.0                  # Create tag
git push origin v1.0          # Push tag
git tag -d v1.0               # Delete local tag
git push --delete origin v1.0 # Delete remote tag

⚙️ Configuration

git config --global user.name "Ajith"
git config --global user.email "you@example.com"
git config --list

✅ This Git reference covers all essential commands for real-world development, version control, and collaboration. Practice them regularly to master Git!