Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on What is the point of triggering CI/CD with an empty git commit?

Parent

What is the point of triggering CI/CD with an empty git commit?

+7
−0

I read posts (e.g., 1, 2, 3) that recommend triggering a CI build process by pushing an empty git commit.

I don't understand how this is a good idea as the commit history will be peppered with meaningless entries, and they can't be removed without re-writing the hashes (e.g., git rebase --interactive, anything from this list), so any clean-up will require a force push (which should be avoided if others also work on that branch).

For example,

BEFORE REBASE:

* c074c70 (HEAD -> master) yet another major item
* bd8e835 trigger CI
* 49ddd75 trigger CI
* f895e9f this is important
* a7da744 trigger CI
* cec6a60 trigger CI
* 96e84f7 init

$ git rebase --interactive 96e84f7

AFTER DROPPING ALL EMPTY COMMITS:

* e441b17 (HEAD -> master) yet another major item
* fc67d54 this is important
* 96e84f7 init

THE ONLY COMMIT THAT RETAINED IT'S ORIGINAL HASH IS "init".
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

Post
+4
−0

Based on the SO comments, this is not a good general practice, and I believe the point of the posts mentioned in the question is that

  • it can be done (but one probably shouldn't)
  • this can be used to test a CI/CD build service/system without having to add a contrived change.

It seems that a good general rule would be to push empty commits only to personal work branches, and remove them before a pull request and/or merging to master/main.


The SO thread Pushing empty commits to remote asks questions (see below) that would answer this thread, but they have been completely ignored there.

Are there any disadvantages/consequences of pushing empty commits? Is there any problem I might face in future because of this empty commit??


Apparently, there is also the practice of starting a repo with an empty commit. Read the post a couple of times, but still don't understand the reasoning (and I suspect that it is perhaps a satirical post).

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

About initial empty commits (2 comments)
About initial empty commits
Karl Knechtel‭ wrote 12 months ago

"Apparently, there is also the practice of starting a repo with an empty commit. Read the post a couple of times, but still don't understand the reasoning (and I suspect that it is perhaps a satirical post)." - it's not satirical; it's straightforwardly a critique of the idea - hence the "doing git wrong" part of the URL. The page introduces the idea as something the author has heard about, presents reasons people have proposed in favour, and then systematically shoots them down.

Anyway, this use of empty commits is not related to the desire to trigger a CI system.

Karl Knechtel‭ wrote 12 months ago · edited 12 months ago

On a closer read, it appears that there are in fact satirical elements. However, the message is still pretty clear: the advice to start with an empty commit is useless and meant as a workaround for non-problems.