📘 Essential Git Commands
A quick reference guide for everyday Git usage.
🛠️ Repository Setup
git init— Create a new Git repositorygit clone <url>— Copy a remote repository to your machinegit config— Set global name/email for Git
📦 Staging & Committing
git status— Show modified/untracked filesgit add .— Stage all file changesgit commit -m "msg"— Save staged changes with a message
🌿 Branching
git branch— List or create branchesgit checkout <branch>— Switch to a branchgit merge <branch>— Merge another branch into current one
🌐 Working with Remotes
git remote add origin <url>— Connect to a remote repogit push -u origin main— Push commits to remotegit pull— Fetch + merge changes from the remote repo
♻️ Undoing Changes
git reset— Unstage a filegit revert <commit>— Undo a commit with a new onegit stash— Temporarily save changes
🧠 Additional Useful Commands
git log --oneline— Compact history viewgit stash pop— Restore stashed changesgit switch -c new-feature— Create and switch to a new branchgit rebase— Clean and reapply commits (advanced)
✅ Use this as a reference when working with Git in your local or collaborative projects!