Git Commands Cheat Sheet: Setup, Workflow, and More

🚀 Git Commands Cheat Sheet: The "Never-Google-Again" List Stop wasting time searching for Git syntax. Save this guide for your next project! 📌 🔹 Setup & Config git config --global user.name "Name" → Set your username git config --global user.email "email@example.com" → Set your email git config --list → View all configurations 🔹 Initialize & Clone git init → Start a new local repository git clone <url> → Copy a remote repository locally 🔹 Basic Workflow git status → Check current status of changes git add . → Stage all changes for commit git commit -m "message" → Save changes with a description git push → Upload local commits to remote git pull → Download and merge latest remote changes 🔹 Branching & Merging git branch → List all branches git checkout -b <name> → Create and switch to a new branch git checkout <name> → Switch to an existing branch git merge <name> → Merge a branch into the current one 🔹 Remote Repositories git remote -v → View remote URLs git remote add origin <url> → Link local repo to a remote server git push -u origin main → Push and set the default upstream branch 🔹 Undo Changes (The Lifesavers 💀) git restore <file> → Discard changes in a specific file git reset <file> → Unstage a file (keep the code) **git reset --hard** → Delete all local changes (⚠️ Use with caution!) git revert <commit> → Undo a commit by creating a new "inverse" commit 🔹 Stashing (Work in Progress) git stash → Hide uncommitted changes to work on something else git stash pop → Bring stashed changes back git stash list → View all stashes 🔹 Logs & History git log --oneline → View a compact history of commits git diff → Show specific line changes between files 🔹 Advanced Tools ⚡ git rebase <branch> → Reapply commits on top of another base git cherry-pick <commit> → Grab one specific commit from another branch git clean -fd → Delete all untracked files and directories Pro Tip: Commit early, commit often. It's better to have too many save points than none at all. 📩 Let’s Connect / Opportunities 📧 yashtiwari.sfdc@gmail.com 📱 8959459494 🔗 my portfolio : https://lnkd.in/dy72e_VF Found this useful? ✅ Like if you learned something new. 🔁 Repost to help a fellow dev. 💬 Comment "GIT" and I'll send you a PDF version! #Git #Programming #Coding #SoftwareEngineering #TechTips #LearnToCode #WebDev

  • text, chat or text message

To view or add a comment, sign in

Explore content categories