š» 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
"Mastering Git: Essential Commands for Developers"
More Relevant Posts
-
š Master Git ā From Basics to Advanced! Whether youāre just starting your developer journey or already pushing code like a pro, understanding Git is non-negotiable. Iāve compiled a complete list of Git commands ā from the simplest to the most advanced ā that every developer should know. If youāve ever felt lost in Git or wanted a single go-to reference ā this post is for you. Repository Setup:- git init -Initialize a new Git repository git clone <repo-url> -Clone an existing repository Basic commands:- git status -Show changed files in working directory git add <file> -Stage a file for commit git add . -Stage all changes git commit -m "message" . -Commit staged changes git rm <file> -Remove a file from the repo and working directory Branching & Merging:- git branch <name> -Create a new branch git checkout <branch> -Switch to another branch git checkout -b <branch> -Create and switch to a new branch git merge <branch> -Merge a branch into the current one git branch -d <branch> -Delete a branch Commands to Access Repository:- git pull -Fetch and merge from remote git push -Push commits to remote repo git push origin --delete <branch> -Delete a remote branch History and Logs:- git log -Show commit history git log --oneline -Condensed commit history git show <commit> -Show details of a specific commit Configuration:- git config --global user.name "Your Name" -Set your username globally git config --global user.email "your@email.com". -Set your email globally git config --list -View all configuration settings git config user.name -Show local username setting Reverting Changes:- git restore <file> -Discard changes in working directory git restore --staged <file> -Unstage a file git reset <file> -Unstage changes (older method) git reset --hard -Reset to last commit, discard all changes git reset --soft HEAD~1 -Undo last commit but keep changes staged git revert <commit> -Create a new commit that undoes a specific commit Tagging Commands:- git tag -List all tags git tag <name> -Create a lightweight tag git tag -a <name> -m "message" -Create an annotated tag git push origin <tag> -Push a tag to remote git push origin --tags -Push all tags git tag -d <tag> -Delete a local tag Advanced Commands:- git cherry-pick <commit> -Apply a specific commit to current branch git rebase <branch> -Reapply commits on top of another git shortlog -Summarize commit history by author Learning With @frontlinesedutech || AI Powered Multi Cloud DevOps Course #flm #frontlinesedutech #frontlinesmedia #MultiCloudDevOps #Git #GitCommands #VersionControl #DevTools #GitHub#OpenSource
To view or add a comment, sign in
-
š Master Git Like a Pro: Essential Commands Every Developer Should Know! Whether you're just starting your coding journey or working on production-grade systems, this Git cheat sheet covers the most important commands to boost your productivity and streamline your workflow. Save it, share it, and level up your version control game! š” š„ General Git Tools š¹ git init ā Start a new repository š¹ git clone <repo> ā Download a remote project to your machine š¹ git status ā Check modified, staged & untracked files š¹ git log ā View commit history š¹ git branch ā List all branches š¹ git checkout <branch> ā Switch branches š¹ git merge <branch> ā Merge changes into the current branch š¹ git stash / git stash pop ā Save & restore uncommitted changes š ļø Staging & Commit Commands š¹ git add <file> ā Stage a specific file š¹ git add . ā Stage everything š¹ git commit -m "message" ā Save changes with a message š¹ git push ā Upload commits to remote š¹ git pull ā Fetch + merge updates š Info & Debugging š¹ git diff ā View unstaged changes š¹ git diff --staged ā View staged changes š¹ git show ā Display commit details š¹ git blame <file> ā See who changed each line š¹ git tag ā List or create version tags š Remote Repository Commands š¹ git remote -v ā Show remote URLs š¹ git remote add origin <url> ā Add a remote repo š¹ git push -u origin <branch> ā Push code & set upstream š¹ git fetch ā Download updates without merging š± Branching Commands š¹ git branch <name> ā Create a new branch š¹ git checkout -b <name> ā Create + switch branch š¹ git switch <branch> ā Switch branches š¹ git branch -d <branch> ā Delete a branch š¹ git merge <branch> ā Merge into current branch š§¹ Cleanup & Maintenance š¹ git clean -f ā Remove untracked files š¹ git gc ā Optimize repository š¹ git fsck ā Check repo integrity š Stash Management š¹ git stash list ā Show all stashes š¹ git stash apply ā Apply a stash safely š¹ git stash pop ā Apply & delete stash š¹ git stash drop ā Remove a stash š Save this for later. š¬ Comment your favorite Git command. š Share to help fellow developers master Git more easily. Letās build smarter, collaborate better, and ship faster! š #Git #GitCommands #GitTutorial #VersionControl #GitHub #DevelopersĀ #SoftwareDevelopment #Programming #Coding #DeveloperTools #DevTipsĀ #CodeNewbie #GitWorkflow #TechTips #CodingTips #OpenSourceĀ #DevCommunity #SoftwareEngineer #WebDevelopment #MobileDevelopmentĀ #Flutter #AndroidDev #ReactNative #Kotlin #JavaScript #CleanCodeĀ #Debugging #BuildInPublic #TechCommunity #Engineering #100DaysOfCodeĀ #Automation #CodeLife #GitForBeginners #TechLearning #ProgrammingLifeĀ #CodeJourney #DeveloperLife #StackOverflow #LearningInPublicĀ #SoftwareEngineering #CodeTips #GitBasics #DevOps #CloudDevelopersĀ #ProductivityTools #GitMerge #GitPush #GitAdd #CommitYourCode
To view or add a comment, sign in
-
-
Commenting Out Code Is Not Version Control Your codebase has 200 lines of commented code "just in case." Delete them. Git remembers. Commented code is actually technical debt. We've all done this at some point: function calculateTotal(items) { return items.reduce((sum, item) => sum + item.price, 0); // Old implementation - keeping just in case // let total = 0; // for (let i = 0; i < items.length; i++) { // total += items[i].price; // } // return total; } "Just in case we need it later." You won't. Delete it. The Problem with Commented Code: ā It confuses new developers. "Should I use this? Is this the right way? Why are there two versions?" ā It makes code harder to read. You're scanning through 50 lines to find 10 that actually run. ā It rots. Commented code doesn't get updated. Six months later, it won't even work if you uncomment it. ā Nobody knows if it's safe to delete. "This has been here for 2 years. Someone must have kept it for a reason, right?" "But What If We Need It?" You have Git. Use it. Git is your time machine. Every deleted line is still there in history. Need to find old code? # Find every commit that added or removed a string git log -S "old function name" --source --all # See the full file from a specific commit git show <commit-hash>:path/to/file.js # Show the entire commit history of a file, even for deleted lines git log --all --full-history -- path/to/file.js If you really need it back, it's a 30-second search away. What to Delete: ā Old implementations - The new code works. Trust it. ā "Maybe we'll need this" - You won't. If you do, Git has it. ā Debugging code - console.log, test data, temporary fixes. ā Experiments that didn't work - Failed approaches don't belong in main. ā TODOs from 2 years ago - If it was important, it would be done. What you can keep: ā Explanations of non-obvious decisions (why this was done this way). ā Documentation comments (JSDoc, docstrings). Open your codebase right now. Search for // or /* or #. How many commented-out lines do you find? Delete 10 of them today. š You're welcome.
To view or add a comment, sign in
-
-
š¤ šš¼š»š³ššš²š± šš¶ššµ šš¶š šš¼šŗšŗš®š»š±š? šš²šæš²āš ššµš² šØš¹šš¶šŗš®šš² š¦š¼š¹ššš¶š¼š» If youāve ever been stuck or confused about the right Git command, donāt worry! Hereās a handy guide to help you streamline your workflow and master Git in no time. š“š¶š š±š¶š³š³: See the changes not yet staged. š“š¶š š°š¼šŗšŗš¶š -š® -šŗ "š°š¼šŗšŗš¶š šŗš²ššš®š“š²": Commit all changes with a message. š“š¶š š°š¼šŗšŗš¶š --š®šŗš²š»š±: Modify the last commit. š“š¶š ššš®ššš: Check the status of your working directory. š“š¶š š®š±š± <š³š¶š¹š²_š½š®ššµ>: Stage your files for commit. š“š¶š š°šµš²š°šøš¼šš -šÆ <šÆšæš®š»š°šµ_š»š®šŗš²>: Create and switch to a new branch. š“š¶š š°šµš²š°šøš¼šš <šÆšæš®š»š°šµ_š»š®šŗš²>: Switch to an existing branch. š“š¶š š°šµš²š°šøš¼šš <š°š¼šŗšŗš¶š_š¶š±>: Checkout to a specific commit. š“š¶š š½šššµ š¼šæš¶š“š¶š» <šÆšæš®š»š°šµ_š»š®šŗš²>: Push your changes to the remote repository. š“š¶š š½šš¹š¹: Fetch and merge remote changes. š“š¶š š³š²šš°šµ: Fetch updates from the remote repository without merging. š“š¶š šæš²šÆš®šš² -š¶: Rebase interactively and rewrite commit history. š“š¶š šæš²šÆš®šš² <šÆšæš®š»š°šµ_š»š®šŗš²>: Rebase your current branch onto another. š“š¶š š°š¹š¼š»š²: Clone a repository to your local machine. š“š¶š šŗš²šæš“š²: Merge two branches together. š“š¶š š¹š¼š“ --ššš®š: See commit logs with stats. š“š¶š ššš®ššµ: Stash your changes temporarily. š“š¶š ššš®ššµ š½š¼š½: Apply and remove stashed changes. š“š¶š ššµš¼š <š°š¼šŗšŗš¶š_š¶š±>: View details of a commit. š“š¶š šæš²šš²š šššš~š: Undo the last commit while keeping the changes locally. š“š¶š šÆšæš®š»š°šµ -š <šÆšæš®š»š°šµ_š»š®šŗš²>: Force delete a branch. š“š¶š šæš²šš²š: Undo commits and move the branch reference. š“š¶š šæš²šš²šæš <š°š¼šŗšŗš¶š_š¶š±>: Revert a commit by creating a new commit that undoes it. š“š¶š š°šµš²šæšæš-š½š¶š°šø <š°š¼šŗšŗš¶š_š¶š±>: Apply changes from a specific commit. š“š¶š šÆšæš®š»š°šµ: List all branches in your repo. š“š¶š šæš²šš²š --šš¼š³š šššš^: Undo the last commit but keep your changes. š“š¶š šæš²šš²š --šµš®šæš±: Hard reset to a previous commit and discard uncommitted changes. š“š¶š šÆšæš®š»š°šµ --šš²š-šš½šššæš²š®šŗ-šš¼ <šæš²šŗš¼šš²_šÆšæš®š»š°šµ>: Set upstream for your branch. š¦š®š š“š¼š¼š±šÆšš² šš¼ š°š¼š»š³ššš¶š¼š» š®š»š± š²š¹š²šš®šš² šš¼ššæ šš¶š š“š®šŗš² šš¶ššµ ššµš²šš² šš¶šŗš½š¹š² š°š¼šŗšŗš®š»š±š #devops #softwareengineering #techcommunity #git #versioncontrol #github #developers
To view or add a comment, sign in
-
-
š Mastering git log ā The Hidden Power of Git History Ever wondered how to explore your Git projectās history like a pro? Most developers just type git log and scroll endlessly ā but Git log can do so much more. Letās uncover some powerful tricks, best practices, and time-saving tips that can turn your Git history into a goldmine of insights š š 1ļøā£ Basic Command git log Shows the commit history in reverse chronological order ā simple, but hard to read for large repos. šØ 2ļøā£ Make Logs More Readable Use the oneline format: git log --oneline š Shows commit hash + message in one line ā perfect for quick overviews. Combine with --graph to visualize branch merges: git log --oneline --graph --decorate --all š This gives you a mini visual branch tree inside your terminal ā super handy for debugging merges. š 3ļøā£ Filter by Author or Date Want to see only your commits? git log --author="Your Name" Need to check commits made last week? git log --since="1 week ago" or between specific dates: git log --after="2024-01-01" --before="2024-12-31" š§ 4ļøā£ Search Specific Messages Search commit messages for keywords: git log --grep="fix" Combine multiple: git log --grep="fix" --grep="bug" š§© 5ļøā£ View File-Specific History Track changes to a single file: git log -- filename.txt Add -p to see exact changes: git log -p filename.txt š” 6ļøā£ Custom Log Formats (Pro Tip ā”) Want clean commit summaries? Try custom formatting: git log --pretty=format:"%h - %an, %ar : %s" Output looks like: a3c6d21 - Anand, 2 days ago : Fixed Docker build issue šÆ Great for creating reports or audit logs. š§ 7ļøā£ See Which Files Changed in Each Commit git log --name-only Or see summary stats: git log --stat Youāll get which files changed + how many lines were added/removed. š§± 8ļøā£ Limit the Number of Commits Sometimes you donāt need the whole history: git log -n 5 Shows only the last 5 commits ā great for quick debugging. š Best Practices ā Use --oneline + --graph in your .gitconfig alias for quick logs. ā Keep commit messages meaningful and structured. ā Regularly review logs before pushing ā helps maintain clean history. ā Use git log -p to audit critical changes in production branches. ⨠Bonus Tip: Create a Shortcut Alias Add this in your .gitconfig: [alias] lg = log --oneline --graph --decorate --all Now simply run: git lg š„ Boom! Your entire Git history in a clean, visual format. š Final Thoughts git log isnāt just a list of commits ā Itās your projectās timeline, audit trail, and debugging partner. Once you master these tricks, youāll navigate your repositories faster, debug smarter, and look like a Git wizard š§āļø š¬ Whatās your favorite git log trick? Drop it below ā letās learn from each other! š š§ Read more: https://lnkd.in/gD9YAAup #Git #DevOps #VersionControl #GitTricks #DeveloperTips #Coding #90DaysOfDevOps #GitHub #Learning
To view or add a comment, sign in
-
š šš”šš¬š šš¢š šš«š¢šš¤š¬ šššÆšš šš š š«šØš¦ ššØš¬š¢š§š š ššš²š¬ šØš ššØš«š¤ ā ššØ šš®ššØš«š¢šš„ ššš„š„š¬ ššØš® šš”š¢š¬. (Real Issues ⢠Real Fixes ⢠Real Industry Knowledge) Everyone knows git add ā git commit ā git push. But nobody talks about the nightmare real-world problems that happen in teams ā and the Git tricks seniors use to fix them in seconds. Here are the battle-tested Git lessons you only learn after š„ breaking production, š„ losing commits, š„ messing up merges, š„ and recovering at 2 AM. Save this ā these WILL save your job one day. š š§ 1ļøā£ āLost All My Work By Accidentā ā Recover With Reflog Problem: You reset, hard deleted, or switched branches⦠and your entire work vanished. Secret Senior Solution: git reflog This shows every movement of HEAD. You can recover commits you thought were dead forever. Real-World Tip: Reflog is your time machine. Every senior dev uses it. Juniors donāt even know it exists. š 2ļøā£ āMy Branch Is 200 Commits Behindā ā Fix With Rebase Problem: Your feature branch diverged from main, causing massive merge conflicts. Secret Senior Move: git pull --rebase Brings your commits ON TOP of latest main. Why Seniors Use It: Cleaner history Fewer conflicts Looks like work was done after mainās changes ā” 3ļøā£ āMerged Wrong Code Into Mainā ā Undo Without Breaking History Problem: You merged a bad PR into main. Solution Seniors Use: git revert <commit-id> Creates a new commit that undoes the wrong merge. Never use: ā git reset --hard on main ā youāll destroy the teamās history. š 4ļøā£ āSomeone Broke the App⦠Who Did It?ā ā Use Git Blame Problem: A bug suddenly appears in production. Secret Senior Tool: git blame <file> Tells you EXACTLY: who wrote that line, when, and in which commit. This saves HOURS of debugging. š 5ļøā£ āA Bug Exists, But I Donāt Know Which Commit Added Itā ā Bisect This is the secret tool seniors SWEAR by. Command: git bisect start git bisect bad git bisect good <old-commit> Git automatically finds the exact commit where the bug was introduced. Massive time saver. šļø 6ļøā£ āI Want To Experiment Without Riskā ā Stash Like a Pro Problem: You need to switch branches urgently, but your current changes are half-done. Senior Fix: git stash push -m "wip-login-feature" Saves your work safely. Later: git stash apply or git stash pop Pro Secret: Keep your stashes named and organized. Juniors use stash blindly and lose work. š§Ø 7ļøā£ āNeed To Bring Only One Commit From Another Branchā ā Cherry-pick Instead of merging a whole branch, do: git cherry-pick <commit-id> When seniors want just one fix, not the whole branch ā this is the trick. š§© 8ļøā£ I Pushed to Wrong Branch!ā ā Safe Reset Do NOT do: git reset --hard on shared branches. Instead: git revert or git reset --soft (keeps your changes staged so you donāt lose work) Follow me Mazharuddin Farooque for more real-world developer insights and senior-level engineering secrets.
To view or add a comment, sign in
-
š How can I figure out who wrote the code, even if it's formatted?! You can use git blame to find out who wrote a line of code, but if the code has been formatted, this command won't help. But! It turns out that if you slightly modify the git blame command, you can enable "detective mode" š git blame -w -C -C -C filename What's happening here: - w - ignores changes in whitespace and formatting. Even if someone ran prettier on the entire project, Git will still find the real author of the logic. - C - looks for duplicate strings within the same commit. For example, if a function was moved to a separate file. - C -C - looks for copies when creating a new file. Useful for refactoring. - C -C -C - goes even deeper, through all commits, to find where the code came from. In short, git blame can be tuned to see through formatting, relocations, and code moves between files. It's really helpful when you need to reconstruct history while debugging or figure out who buried a bug in the past (yes, usually it's you š ). Useful links: Documentation https://lnkd.in/dMfhGstM How to exclude formatting commits: https://lnkd.in/ddzc9see #git #gitblame #developerlife #refactoring #devtools
To view or add a comment, sign in
-
Ever worked on a shared repo and thought, āI just want to ignore my .vscode/ folder⦠why is this so hard?ā š Happens all the time! Especially in open source projects where maintainers donāt include editor configs in .gitignore, or when youāre using something experimental like Claude Code or Cursor that drops its own .claude, .cursor, CLAUDE.md, etc. You donāt want to commit those files, but you also donāt want to mess with the projectās .gitignore. Turns out, Git already has a built-in solution for this: š .git/info/exclude It works just like .gitignore, but itās local-only. So your personal ignore rules stay on your machine and never pushed to remote. And hereās a neat trick: create a .gitignore.local, symlink to it, so you can manage your local ignores right from the project root. I even added a tiny script + shell function so you can set it up instantly in any repo. Full write-up here -> https://lnkd.in/dz7aYD5d Tiny improvement, huge quality-of-life gain. Once you start using it, youāll never go back š #Git #DevTips #OpenSource #DeveloperExperience #CLI
To view or add a comment, sign in
-
Git commands every developer should know with cheatsheet https://lnkd.in/gMNpS-YK 1. Git Setup and Configuration git config --global user.name "Your Name" git config --global user.email "your.email@example.com" git config --listView all Git configurations git config --global core.editor "code --wait" 2. Starting a Repository git init Initialize a new Git repository git clone <repo_url> Clone an existing repository git remote add origin <repo_url>Connect local repo to remote git remote -v View configured remotes 3. Working with Files git status Check repo status (modified, staged, etc.) git add <file>Stage a specific file git add .Stage all changes git restore <file> Discard changes in working directory git diff View unstaged changes git diff --stagedView staged changes 4. Committing Changes git commit -m "message" Commit staged changes git commit -am "message" Add and commit tracked files in one step git log View commit history git log --oneline --graph --decorate --all Pretty, compact commit graph git show <commit_id> Show details for a specific commit 5. Branching & Merging git branch List all branches git branch <name> Create a new branch git switch <branch> / git checkout <branch> Switch to another branch git merge <branch> Merge a branch into the current one git branch -d <branch> Delete a local branch git branch -m old_name new_name Rename a branch 6. Working with Remotes git fetch Download changes from remote (no merge) git pull Fetch + merge changes git pull --rebase Fetch + rebase changes git push Push commits to remote git push -u origin <branch> Set upstream branch for first push git push origin --delete <branch> Delete a remote branch 7. Undoing Changes git reset <file> Unstage a staged file git reset --hard Reset to last commit (destroy local changes) git reset --hard <commit_id> Reset to a specific commit git revert <commit_id> Create a new commit undoing previous commit git restore --source=HEAD <file>Restore a file to last commit state 8. Stashing (Temporary Save) git stash Save uncommitted changes temporarily git stash lis tList all stashes git stash apply Reapply last stash git stash pop Apply and remove stash git stash drop Delete a specific stash 9. Tagging (for Releases) git tag List tags git tag <name> Create a lightweight tag git tag -a <name> -m "message" Create an annotated tag git push origin <tag> Push tag to remote git push origin --tags Push all tags 10. Inspection & Debugging git blame <file> Show who changed each line and when git log -S <keyword> Search commits containing a specific keyword git grep <pattern> Search across files git bisect Find the commit that introduced a bug Watch my youtube channel - https://lnkd.in/gkB27ZDF Connect with me on Instagram - https://lnkd.in/gYG3QNfh PS: Do share and save the post with your friends and community and follow Praveen Singampalli for any job help
To view or add a comment, sign in
-
-
Git strategy cheat sheet that I believe will be a valuable resource for everyone⦠It helps streamline our workflow and improve our understanding of GIT.
Helping Students & Professionals Get Jobs | Built 300k+ DevOps Family Across Socials | AWS Community Builder | Ex-Verizon | Ex-Infosys | 8x SSB Conference Out
Git commands every developer should know with cheatsheet https://lnkd.in/gMNpS-YK 1. Git Setup and Configuration git config --global user.name "Your Name" git config --global user.email "your.email@example.com" git config --listView all Git configurations git config --global core.editor "code --wait" 2. Starting a Repository git init Initialize a new Git repository git clone <repo_url> Clone an existing repository git remote add origin <repo_url>Connect local repo to remote git remote -v View configured remotes 3. Working with Files git status Check repo status (modified, staged, etc.) git add <file>Stage a specific file git add .Stage all changes git restore <file> Discard changes in working directory git diff View unstaged changes git diff --stagedView staged changes 4. Committing Changes git commit -m "message" Commit staged changes git commit -am "message" Add and commit tracked files in one step git log View commit history git log --oneline --graph --decorate --all Pretty, compact commit graph git show <commit_id> Show details for a specific commit 5. Branching & Merging git branch List all branches git branch <name> Create a new branch git switch <branch> / git checkout <branch> Switch to another branch git merge <branch> Merge a branch into the current one git branch -d <branch> Delete a local branch git branch -m old_name new_name Rename a branch 6. Working with Remotes git fetch Download changes from remote (no merge) git pull Fetch + merge changes git pull --rebase Fetch + rebase changes git push Push commits to remote git push -u origin <branch> Set upstream branch for first push git push origin --delete <branch> Delete a remote branch 7. Undoing Changes git reset <file> Unstage a staged file git reset --hard Reset to last commit (destroy local changes) git reset --hard <commit_id> Reset to a specific commit git revert <commit_id> Create a new commit undoing previous commit git restore --source=HEAD <file>Restore a file to last commit state 8. Stashing (Temporary Save) git stash Save uncommitted changes temporarily git stash lis tList all stashes git stash apply Reapply last stash git stash pop Apply and remove stash git stash drop Delete a specific stash 9. Tagging (for Releases) git tag List tags git tag <name> Create a lightweight tag git tag -a <name> -m "message" Create an annotated tag git push origin <tag> Push tag to remote git push origin --tags Push all tags 10. Inspection & Debugging git blame <file> Show who changed each line and when git log -S <keyword> Search commits containing a specific keyword git grep <pattern> Search across files git bisect Find the commit that introduced a bug Watch my youtube channel - https://lnkd.in/gkB27ZDF Connect with me on Instagram - https://lnkd.in/gYG3QNfh PS: Do share and save the post with your friends and community and follow Praveen Singampalli for any job help
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Thanks for sharing...