๐ Git & GitHub Cheat Sheet
๐ง Git Configuration
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --list
๐ Create & Clone
git init # Initialize a new repo
git clone <url> # Clone an existing repo
๐ Basic Workflow
git status # Show changed files
git add <file> # Stage a file
git add . # Stage all changes
git commit -m "message" # Commit with a message
git push # Push to remote repo
git pull # Pull latest changes
๐ฟ Branching
git branch # List branches
git branch <name> # Create new branch
git checkout <name> # Switch branch
git checkout -b <name> # Create & switch
git merge <name> # Merge a branch
๐งน Undo & Reset
git restore <file> # Undo changes in working directory
git reset <file> # Unstage a file
git reset --hard # Reset everything to last commit
๐ Stashing
git stash # Save changes
git stash pop # Reapply stashed changes
git stash list # Show stash list
๐ Logs & Diffs
git log # View commit history
git log --oneline # Condensed log
git diff # Show changes
๐ Remotes
git remote -v # Show remotes
git remote add origin <url> # Add remote
git push -u origin main # Push and set upstream
๐ GitHub Authentication
- Use SSH keys or GitHub CLI for authentication.
๐ ๏ธ Miscellaneous
git tag <tagname> # Create a tag
git fetch --all # Fetch all remotes
git cherry-pick <hash> # Apply a specific commit