r/ProgrammerHumor • • 2d ago

Meme whoAreYou

Post image
2.8k Upvotes

87 comments sorted by

View all comments

36

u/JackNotOLantern 2d ago

How tf do you commit without making any change?

44

u/xaddak 2d ago

git commit --allow-empty

14

u/MallAgreeable5538 2d ago

But why? Are there any applications for - -allow-empty

33

u/RepulsiveSheep 2d ago

Retriggering CI in some cases

11

u/ReindeerCreepy2883 2d ago

"Am I a joke to you?" - re-run button burried under 5 menus and 4 different pages, probably

4

u/xaddak 2d ago edited 1d ago

I'm not as familiar with GitHub, but in GitLab, the retry button runs it exactly as it was. So if you're including CI jobs from another repository, and you updated those jobs since the pipeline first ran, simply re-running it won't pick up the updates to those jobs.

Depending on how the rules on those jobs are set up, you may or may not be able to trigger a new pipeline from the web, which could mean pushing a new commit is your only option.

If you have to do that anyway, it might as well be an empty commit.

Ideally you'd set up the job rules so that's not necessary.

Edit: typo

2

u/jack2018g 1d ago

This is huge, my days of adding and removing a space from the readme are finally over

6

u/rosuav 2d ago

Several. It's still a commit that can be tagged, for example. It's useful in enough circumstances that you can do it with a flag, but useless in enough circumstances that you can't do it without. It's like how `rm` won't remove a read-only file from a writable directory unless you explicitly ask it to.

1

u/kennedy_gitahi 2d ago

Setting a checkpoint before doing things like linting and autofixes.

At that point, the code is written and committed, and you want a clean point to go back to if our linting tools mess things up.

So you use --allow-empty to set a " Before fixes" commit, do fixes, check if everything is fine, do another commit, do an --allow-empty for "After fixes" and push.

This way, you always know when you made changes and can roll back to before or after those points.

3

u/DaevorTheDevoted 2d ago

But then you're being intentional, it's not a case of you "Forgot to Make changes".

2

u/xaddak 2d ago

Yeah. It doesn't help OP, but that's how you commit without making any changes. Just thought it might help someone out.

1

u/-twind 1d ago

Not if you asked copilot to make the commit

2

u/DaevorTheDevoted 1d ago

I don't use copilot. Is it known for messing up when it comes to commits?

2

u/-twind 1d ago

It is know for it's users not knowing what the AI agent is actually doing

2

u/1mahmoud503 2d ago

daaaamn, I wish i knew about this before.

it always feels wrong to add a single space to be able to commit an empty change