DEV Community

Harikrishnan N
Harikrishnan N

Posted on

2 1

๐Ÿš€ Level Up Your GitHub Game: Advanced Git Commands You Should Know!

Hey devs! ๐Ÿ‘‹

We all know the basics: git clone, git commit, git push...

But Git has superpowers most people don't use! ๐Ÿ’ฅ

Let's dive into some advanced Git commands that'll seriously upgrade your workflow.


1. git cherry-pick <commit-hash>

๐Ÿ”น Use case: Pick a single commit from one branch and apply it to another.

git cherry-pick abc1234
Enter fullscreen mode Exit fullscreen mode

โœ… No need to merge the whole branch โ€” just grab what you need!


2. git stash save "message"

๐Ÿ”น Use case: Pause your work and jump to another task without losing changes.

git stash save "WIP: fixing bug"
Enter fullscreen mode Exit fullscreen mode

Then later:

git stash pop
Enter fullscreen mode Exit fullscreen mode

โœ… Instantly resume where you left off!


3. git rebase -i HEAD~n

๐Ÿ”น Use case: Interactive rebase to clean up your messy commit history.

git rebase -i HEAD~5
Enter fullscreen mode Exit fullscreen mode

You'll be able to squash, edit, or delete commits like a boss. ๐Ÿงน


4. git reflog

๐Ÿ”น Use case: Lost a commit? Deleted a branch?

git reflog
Enter fullscreen mode Exit fullscreen mode

โœ… Find the commit ID and bring it back. Git never forgets! ๐Ÿ˜‰


5. git reset --soft HEAD~1

๐Ÿ”น Use case: Undo the last commit, but keep your changes in the staging area.

git reset --soft HEAD~1
Enter fullscreen mode Exit fullscreen mode

โœ… Great when you realize, "Oops, wrong commit message!"


6. git bisect

๐Ÿ”น Use case: Find which commit broke your code by binary search! ๐Ÿ”ฅ

git bisect start
git bisect bad
git bisect good <commit-hash>
Enter fullscreen mode Exit fullscreen mode

Git will now guide you step-by-step to find the guilty commit.


7. git remote prune origin

๐Ÿ”น Use case: Clean up branches that were deleted on GitHub but still show locally.

git remote prune origin
Enter fullscreen mode Exit fullscreen mode

โœ… Keep your repo fresh and tidy!


8. git shortlog -s -n

๐Ÿ”น Use case: See who contributed the most (or least) to your project.

git shortlog -s -n
Enter fullscreen mode Exit fullscreen mode

โœ… Fun way to spot the hidden heroes on your team! ๐ŸŒŸ


โœจ Bonus Tip: Aliases = Speed Boost

Tired of typing long commands?

Set an alias like:

git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.cm "commit -m"
Enter fullscreen mode Exit fullscreen mode

Now you can simply run git co main instead of git checkout main! ๐Ÿš€


๐ŸŽฏ Final Words

Git isn't just a tool โ€” it's a superpower when you know how to use it well.

Master these advanced commands and Git Good! ๐Ÿ˜Ž


Heroku

Amplify your impact where it matters most โ€” building exceptional apps.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (1)

Collapse
 
nevodavid profile image
Nevo David โ€ข

Reading those makes me wish I actually used half of them day-to-day. You think having too many tools ever slows you down, or does it always help in the long run?