"Mastering Git: Essential Commands for Developers"

šŸ’» The Ultimate Git Command Cheat SheetĀ  "Git is an essential tool for every developer, powering everything from version control to CI/CD pipelines. Below is a comprehensive list of must-know Git commands with concise explanations:" 🧩 Setup & Config Configure your identity and preferences. git config --global user.name "Your Name" git config --global user.email "you@example.com" git config --listĀ Ā Ā Ā Ā  # View configuration šŸ Repository Basics git initĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā  # Create a new repo git clone <url>Ā Ā Ā Ā  Ā  # Copy a remote repo git statusĀ Ā Ā Ā Ā Ā Ā Ā Ā  # Check file status git add .Ā Ā Ā Ā Ā Ā Ā Ā Ā  Ā  # Stage all changes git commit -m "message"Ā Ā # Commit changes git log --onelineĀ Ā Ā Ā Ā  # View commit history 🌿 Branching & Merging git branchĀ Ā Ā Ā Ā  Ā # List branches git branch feature/loginĀ Ā  Ā  # Create a branch git checkout feature/loginĀ Ā  # Switch to branch git merge feature/loginĀ Ā  Ā # Merge into current branch git merge --abortĀ Ā Ā  Ā Ā # Cancel merge conflict git branch -d feature/loginĀ  Ā # Delete branch šŸš€ Remote Repositories git remote -vĀ Ā Ā Ā Ā Ā  # Show remotes git fetch originĀ Ā Ā Ā Ā  # Download updates git pull origin mainĀ Ā Ā Ā  # Pull + merge updates git pull --rebase origin mainĀ Ā  # Rebase instead of merge git push origin mainĀ Ā Ā Ā  # Push commits git push --set-upstream origin feature/api # Push new branch 🧰 Undo & Fix git revert <commit>Ā Ā Ā Ā # Undo a commit safely git reset --soft <commit>Ā Ā Ā # Undo, keep staged git reset --hard <commit>Ā Ā Ā # Undo completely git restore <file>Ā Ā Ā Ā # Restore file git checkout <commit> -- <file>Ā # Get old version of file šŸ’ Cherry-Pick (Selective Commit) Apply specific commits from another branch. git cherry-pick <commit> šŸ“¦ Stash (Temporary Save) Save your current work to switch tasks quickly. git stashĀ Ā Ā Ā Ā Ā Ā # Save uncommitted changes git stash listĀ Ā Ā Ā Ā # View stashes git stash applyĀ Ā Ā Ā Ā # Reapply stash git stash dropĀ Ā Ā Ā Ā # Delete stash 🧠 Rebase & Squash Clean up your history and combine commits. git rebase mainĀ Ā Ā Ā Ā # Move commits onto another branch git rebase -i HEAD~3Ā Ā Ā Ā # Interactive squash/fixup šŸ” Bisect (Find Bugs Fast) Identify the exact commit that introduced a bug. git bisect start git bisect badĀ Ā Ā Ā Ā # Mark current commit bad git bisect good <commit>Ā Ā Ā # Mark old commit good git bisect resetĀ Ā Ā Ā Ā # End bisect 🧹 .gitignore Exclude files and folders you don’t want to track. node_modules/ *.log .env __pycache__/ git rm -r --cached .Ā Ā Ā Ā # Remove tracked ignored files šŸ”” Webhooks (Automation) Webhooks let Git repos trigger CI/CD or notifications automatically. #Git #GitCheatSheet #DevOps #SoftwareEngineering #VersionControl #CodingTips #Programming #Developers #OpenSource #Productivity #Cloud #TechCommunity #Learning #CodeQuality #CI/CD #GitHub #TechTips

Like
Reply

To view or add a comment, sign in

Explore content categories