Git & GitHub Cheat Sheet

Thursday, May 22, 2025

๐Ÿ™ 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.
ssh-keygen -t ed25519 -C "[email protected]"
gh auth login              # GitHub CLI login

๐Ÿ› ๏ธ Miscellaneous

git tag <tagname>          # Create a tag
git fetch --all            # Fetch all remotes
git cherry-pick <hash>     # Apply a specific commit
Commandsdocumentationcheatsheetgithub

Video Ideas

Linux Commands Cheat Sheet