Empty commits play a significant role in enhancing version control workflows. Although seemingly counterintuitive, they offer valuable benefits for...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
I never used empty commits, actually didn't even know it was possible.
Still, I'm not totally sure that can help more to document than a well written commit with the relative code; and for triggering automations, most platforms gives the chance to trigger them manually, so no need for an empty commit to do that. Maybe I'm the one who's losing the point here, I'm really open and curious to better understand this empty-commit thing.
Still, thank you for the article, it's indeed really interesting, I learnt something new
Empty commits are used in the PR. I have seen projects like Kubernetes and Flutter use this for triggering the CI and tests.
Oh nice, it makes everything clearer, thank you! This makes actually more sense to me now :D Thank you for the clarification!
this is so wrong.. if you want to trigger the CI just push the button in whatever platform you're using (Azure, gitlab, github, etc)
Empty commits are a bad practice.
I disagree. Read this
dev.to/pradumnasaraf/comment/2810p
I already read thst. it's ok, you have the right to be wrong. If you dont have access to run a CI it's just because you don't have the right level of access to those tools. You could argue that you squash commits before merge but you don't.. Empty commits are just a patch for (in that example) poor permission or access management.
While there might be edge cases for empty commits, it really is good practice to always provide context for commits with a concise message. Having said that, I'm curious if anyone uses empty commit messages in a production environment.
We often need to do it to rerun broken pipelines... due a messy architecture we have at work a pipeline dependent on subpipelines and 3rd party projects pipelines. Sometimes, cleaning the caches and rerunning it is not enough to solve an issue, so a clean chain needs to be triggered... therefore empty commits. (They are actually used in the MRs so they will be squashed in master).
Empty commits are used in the PR. I have seen projects like Kubernetes and Flutter use this for triggering the CI and tests.
I used empty commit messages often at my last job for 2 main reasons
1) the most useful was setting a clear reset point if things went wrong. When I started a new feature branch I would immediately create a new empty commit. that way reviewing the history after a merge there's a clear line in the sand when new work began. very helpful for figuring out when / where a new bug was introduced
2) as a small rebellion. at a previous company we had git metrics that would measure how many commits per day you had in comparison to your peers. These metrics at a surface level were useless and imo were an over reaction to a few bad apples when the company went fully remote and they just stopped working.
so in retaliation I and a few of my teammates started using empty commits to help pad our numbers (our manager was aware and on board with our small rebellion as he also wasn't a fan of these terrible metrics)
I'm using it when I wish to rerun my CI jobs.
I'm using a repo with template so when I change that repo (the one with templates), then I should rerun my CI and empty commits are really useful then..
Can't you just have the parent ci trigger the child ci.
It's a common feature for most ci vendors
Likewise
which CI do you use, I currently have workflows on GitHub, GCP and Azure, previous company was AWS and they all have buttons to run the pipeline?
I work with GitHub Actions, but on projects with hundreds of maintainers, you don't have direct access to CI or third-party buttons/mutual triggers. Bots are used to merge the PRs and ask for an empty commit to be pushed because that is the only way to rerun the CI.
If you see projects like Kubernetes, Flutter, etc., they also follow the same pattern.
Thanks for the nice article. I certainly have been there where I needed a job run but the only way to trigger it to make a commit that wasn't needed.
For GitHub actions, we have stared using workflow-dispatch , that lets you manually trigger a workflow
I never even knew this existed. It seems really useful though.
Thank you.
Great article! This clarifies a lot about the practical utility of empty commits. I have a question though, is there a specific scenario where using empty commits might be discouraged or considered bad practice? I'm wondering if there are any 'dos and don'ts' when it comes to using empty commits in a collaborative environment.
Thank you. Yes, you should not be using it on the
mainbranch and should only use it on PRs.Possibly, one exception for the not-on
mainrule: empty initial commit on a new repo.Can Tagging be another alternative to this..
git-scm.com/book/en/v2/Git-Basics-...
What ? ( ˙▿˙ )
Nobody has ever told me this before.
Learned something new.
Thank you.
Wish i knew this allow empty flag before making a redundant space to make a ci trigger commit last week. Thanks for sharing.
Gret one. Learned something new
Thank you
Awesome
Thank you.
I don't see an useful purpose for this, unless the sheer curiosity.
It will just add more blank entries to the history, and if you have lots and lots of them, it will make to search for useful entries more difficult.
I suppose you haven't worked in teams with hundreds of maintainers, where bots are used to merge the PRs and ask for an empty commit to be pushed because that is the only way to rerun the CI.
Did you know you can choose to commit a file with the exact same contents over multiple commits, without worrying about needing to rebase or address conflicts?
I only found out while using GitHub API via JS. I even checked their UI to see if behind the scenes it was an empty commit. It was not.
Lots of odd things you can do with git. Likely there are very good reasons you should not though 😉
Check out projects like Kubernetes, Flutter, etc., and you will understand why you need this in PRs. 😉
Okay so I am thinking that it is not a good idea to create a empty meaning because a commit name is meant to describe it's change so if you don't do any changes there should not be a commit name so no commit at all.
However, I don't have enough information on why you are using them to trigger CI
I am assuming that you are using GitHub in my recommandation
Empty commits are useful in cases where you want to generate builds some change in sub module projects or dependency projects, so that latest build includes those build.
I have known only few command in git, it was new to me and got some knowledge, thank you
I hope you have also tried: Automated AI commits maybe more interesting.
Git is a total mess. One more, one less? Meh.
Thanks for sharing !
This is not the solution if you want an automated release using Github Actions for private npm packages.
This is not used to push directly to the main branch and cluttering the git history. It is used in PRs to trigger CI and tests.