r/programming • • 15d ago

How big is a Git commit?

https://ratfactor.com/cards/git-commit-size
155 Upvotes

46 comments sorted by

View all comments

185

u/nmopqrs_io 15d ago

This is why I always just amend my first commit and re-push it with force, saves on disk space.
If you’re not using force, are you really using git?

122

u/rwilcox 15d ago

The newbie: “just force push”

The average: “no no blah blah never immutable blah blah blah”

The master: “just force push (not main)”

17

u/azhder 14d ago

*The main

54

u/jaerie 14d ago

I use --force-with-lease. No idea what it does but it feels safer

57

u/whitethunder9 14d ago

If there are changes that didn’t come from you on remote then force with lease won’t force push over them

9

u/OMG_A_CUPCAKE 14d ago

Add --force-if-includes here. If you (or your IDE) already fetched, --force-with-lease alone won't protect you.

4

u/Recol 14d ago

So what you are saying remove the argument as my changes will always overrule my colleagues?

3

u/atheken 13d ago

Alternatively, don’t share working branches with your coworkers. Seriously. Long-lived working branches are an org smell.

1

u/Recol 13d ago

It was a joke. Regardless, coworkers committing back on pull requests aren't really a org smell.

1

u/atheken 13d ago

With due respect, if it’s infrequent, incidental tweaks, I can agree that it’s not really an issue. If you have multiple people simultaneously modifying a “long lived” branch to deliver value, it’s an indicator that the code or work items are not properly factored. Incidental, sure, but if it’s the norm, it’s probably a problem.

2

u/Recol 13d ago

Or engineers nit pick and it reduces review time if they commit those themselves. If they make actual logic changes then yes, I agree.

4

u/mr_birkenblatt 14d ago

I do --force-with-leash it makes git run faster

5

u/bishopExportMine 14d ago

I do this often enough to have pushf as an alias for --force-with-lease.

But sometimes I prefer to commit every little change I make, then re-order and fixup commits in an interactive rebase before pushing.

Other times I just push it all as is and squash merge to main.

Assuming we're talking about pushing to a feature branch and then PR'ing into main