Forem

Cover image for 10 Secret Git Commands That Will Save You 5+ Hours Every Week

10 Secret Git Commands That Will Save You 5+ Hours Every Week

Arpit Gupta on February 15, 2025

Let’s be honest — Git can feel like a double-edged sword. On one hand, it’s the backbone of modern software development. On the other, it’s a labyr...
Collapse
 
instalab profile image
Samuel Boczek

Initially sceptical, but I am satisfied with this article. 👍

Collapse
 
arpitstack profile image
Arpit Gupta

Glad you found it useful!

Collapse
 
moopet profile image
Ben Sinclair

TIL range-diff, notes, and worktree.

I'm not so sure I see the point in worktree, given you can checkout a different branch to a different folder anyway, but the cost is that it gets confusing as to which is which.

If you name the folders after their branch, e.g. "myproject-develop" and then in the future want to switch branch, then you have two things you need to keep in sync.

...unless that different folder's git metadata is held in one place. That'd save you a lot of disk space, potentially.

The cost there is that if you decide you don't need one of the folders any more and delete it, you might delete the one with the metadata in it!

I haven't tried it yet, but I think it sounds a little faustian.

On the other hand, while I was generally aware of sparse-checkout, I never bothered to find out what it actually did until now. Where I've seen it before, usually in CI jobs, it's just been something I've assumed gave you a bare repository!

Collapse
 
arpitstack profile image
Arpit Gupta

Good points on worktree! The centralized metadata does help with disk space, but as you said, it also adds a layer of risk if a key folder gets deleted. I guess it’s useful if you frequently switch between branches but want to avoid duplicate repositories.

Sparse-checkout is something I also overlooked before—curious to see if it improves workflows in practice!

Collapse
 
chris_sd_b9194652dbd4a1e profile image
Chris S-D

Git bisect is the best. Can't tell you how many times it's helped me find issues quickly.

Main thing, though, is that it's helpful if committers try to make sure they are always committing code that doesn't break in an obvious way. It can be hard to bisect when you land on a specific commit that doesn't build and has nothing to do with the problem you're looking for.

Collapse
 
arpitstack profile image
Arpit Gupta

That's true. Thanks for sharing!

Collapse
 
j-256 profile image
James

Thanks! Actually learned something instead of the usual "here are 10 commands you definitely use every day already".

Collapse
 
arpitstack profile image
Arpit Gupta

Indeed! Couldn't agree more.

Collapse
 
onlyfave profile image
Favour Onyeneke

Really helpful article
Well done Arpit!

Collapse
 
arpitstack profile image
Arpit Gupta

Made my day, thank you :)

Collapse
 
arseniydev profile image
Arseniy

I really liked the git bisect I wish I new about it before. Thank you for sharing it.

Collapse
 
arpitstack profile image
Arpit Gupta

Happy to help :)

Collapse
 
john_mitchell_4185d0dd9ed profile image
John Mitchell

solid! Subscribed

Collapse
 
arpitstack profile image
Arpit Gupta

Loved it, thank you so much John :)

Collapse
 
kurealnum profile image
Oscar

Really well written!

Collapse
 
arpitstack profile image
Arpit Gupta

Thnkew!

Collapse
 
citronbrick profile image
CitronBrick

This article deservers at least thrice the reactions.

Collapse
 
arpitstack profile image
Arpit Gupta

Your comment made my day! Thanks a ton, Citron.

Collapse
 
fahadullah profile image
Fahad Ullah

Really very informative article, specially git bisect is awesome. Thanks for sharing such a valuable content with us

Collapse
 
arpitstack profile image
Arpit Gupta

Means a lot, thanks a ton Fahad!

Collapse
 
snowandcaffeine profile image
snowandcaffeine

I love lazygit for the same reason, keeps me from having to google things I don't do daily:

github.com/jesseduffield/lazygit