There are a lot of Git commands. I'm always discovering a new and useful one. This time I have found one that allows you to push an empty commit to a repository.
Why push an empty Git commit?
Git doesn't allow you to push commits without making changes, and there are times when you don't want to make changes but perhaps trigger a pipeline or job or build that is attached to a repository.
This is where pushing an empty commit can come in handy. If you can't manually trigger your build or pipeline, staying in the command line prompt and pushing an empty commit can mean triggering the build or pipeline without making any changes.
How to push an empty commit
It is a fairly straight forward command, using the --allow-empty flag.
git commit --allow-empty -m "Empty commit"
Very similar to pushing a commit when you've made changes to your code. But using this flag you can push a commit without making any changes. 😊
Top comments (1)
Empty commits are such a handy tool for testing.