You’re probably already a pro at using Git’s ‘A-list’ commands: git commit, git push, and git pull. But beyond these, there are powerful commands that often fly under the radar. Not only can they save you time, but they can also change the way you think about version control.
Imagine You’re deep into coding a new feature, and suddenly, a high-priority bug report interrupts you. You don’t have to rush to commit your half-done code.
Instead, you can just “stash” it away safely. This lets you fix the urgent bugs first and then easily get back to your feature work.
git stash save "Work in progress for new feature"
Finding a new bug is like looking for a needle in a haystack of commits. Don’t bother going through each one individually —
git bisect is a more efficient way to find bugs.
Using a binary search algorithm, it quickly identifies the problematic commit causing the problem.
git bisect start git bisect bad git bisect good [good_commit]
Imagine you’ve spotted a great fix or feature in another branch. Instead of dragging along all the other commits through a merge, why not
‘cherry-pick’ just the genius you need?
git cherry-pick [commit_hash]
Have you ever wished you could roll back a botched git command? Enter
git reflog. It keeps a record of every move you’ve made, making it easy to turn back the clock and recover lost commits.
Before you release your excellent new feature, cleaning up your commit history is a good idea. Interactive Rebase (
git rebase -i) lets you reorder, squash, or amend commits, creating a polished history that’s easy to follow.
git rebase -i [base_commit]
Git offers so much more than the popular commands we use daily. These less-used commands can supercharge your workflow, make it easy to track bugs, and even save your day in case of emergency commits.
So, exploring these Git’s lesser-known features and learning will make your coding workflow smoother. Not only will you become a more capable developer, but you will also take your version control to new heights.
Which of these Git commands are new to you? Have you encountered a situation where one could have been a lifesaver? Share your experiences, tips, and tricks in the comments below.