🖋 Introduction

Git is the heart of modern development workflows. While most developers are familiar with git add, git commit, and git push, there's a whole world of advanced Git commands that can save time, prevent disasters, and help you debug like a pro. Let’s level up!

🔍 Why Go Beyond the Basics?

Understanding advanced Git operations helps:

Clean up messy histories

Fix mistakes without panic

Navigate and debug efficiently

Collaborate more effectively

⚙️ Advanced Git Commands

  1. git reflog – Your Time Machine
    bash
    Copy
    Edit
    git reflog
    Shows a log of where your HEAD and branch references have been. Useful for recovering lost commits!

  2. git cherry-pick – Pick and Choose Commits
    bash
    Copy
    Edit
    git cherry-pick
    Apply specific commits from one branch into another. Great for patching bugs without merging entire branches.

  3. git bisect – Debugging Power Tool
    bash
    Copy
    Edit
    git bisect start
    git bisect bad
    git bisect good
    Use binary search to find the exact commit that introduced a bug. Super handy in large codebases.

  4. git stash – But Make It Fancy
    bash
    Copy
    Edit
    git stash save "WIP: fixing navbar"
    git stash list
    git stash pop
    Temporarily shelve your changes. You can even apply them selectively using stash@{n}.

  5. git rebase -i – Rewrite History Like a Boss
    bash
    Copy
    Edit
    git rebase -i HEAD~3
    Interactive rebasing lets you squash, edit, or reorder commits. Use it to clean up your commit history before a PR.

  6. git reset – Know Your Levels
    bash
    Copy
    Edit
    git reset --soft HEAD~1
    git reset --mixed HEAD~1
    git reset --hard HEAD~1
    Roll back commits with precision. Soft keeps your changes, hard doesn’t.

  7. git clean – Remove the Untracked
    bash
    Copy
    Edit
    git clean -fd
    Clears untracked files and directories. Be careful—it’s permanent!

  8. git blame – Find Who Changed What
    bash
    Copy
    Edit
    git blame
    Annotates each line in the file with the commit and author. Useful for tracking bugs or changes.

  9. git log – But Prettier
    bash
    Copy
    Edit
    git log --oneline --graph --decorate --all
    See a visual, colorful graph of your commit history. Great for understanding merges and branches.

🚀 Pro Tips
Use aliases for long commands (git config --global alias.lg "log --oneline --graph --decorate")

Combine git stash with git checkout to switch branches safely

Before a pull request, use git rebase -i to squash commits

📚 Conclusion
These commands will give you superpowers in managing Git repositories. Don’t fear the terminal — embrace it. The more fluent you get with Git, the smoother your dev life will be.

🔗 Further Reading

📘 Pro Git Book
https://git-scm.com/book/en/v2

📝 Git Cheatsheet by GitHub Education
https://education.github.com/git-cheat-sheet-education.pdf

🧠 Learn Git Branching (Interactive Visual Tool)
https://learngitbranching.js.org