r/ProgrammerHumor • • Oct 01 '26

Meme whoAreYou

Post image
3.0k Upvotes

89 comments sorted by

View all comments

39

u/JackNotOLantern Oct 01 '26

How tf do you commit without making any change?

48

u/xaddak Oct 01 '26

git commit --allow-empty

13

u/MallAgreeable5538 Oct 01 '26

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

37

u/RepulsiveSheep Oct 01 '26

Retriggering CI in some cases

11

u/ReindeerCreepy2883 Oct 01 '26

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

6

u/xaddak Oct 01 '26 edited Oct 02 '26

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 Oct 02 '26

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

6

u/rosuav Oct 01 '26

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/A_Philosophical_Cat Oct 05 '26

Not so much in the more common workflows, but remember that git is designed to be incredibly flexible. Maybe you want to indicate that all descendants of this commit are to be excluded from Release 26.1. Maybe you want to trigger some secondary review process, based on changes that aren't captured in Git. Maybe you have some zany review process where reviewers submit their feedback as a git commit message on a blank commit.

1

u/kennedy_gitahi Oct 01 '26

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 Oct 01 '26

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

2

u/xaddak Oct 01 '26

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 Oct 01 '26

Not if you asked copilot to make the commit

2

u/DaevorTheDevoted Oct 01 '26

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

2

u/-twind Oct 01 '26

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

2

u/1mahmoud503 Oct 01 '26

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

3

u/Shitandasshole Oct 01 '26

--allow-empty

2

u/__Invisible__ Oct 01 '26

bump version then forget to merge branch

2

u/ellamking Oct 01 '26

You script it and don't look at the results.

1

u/[deleted] Oct 03 '26

I just don't care if commit fails.

-1

u/christian_austin85 Oct 01 '26

I had the same thought. Working tree is clean, nothing to commit.