DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 967,911 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for How to Push an Empty Commit in Git
Sarah Lean 🏴󠁧󠁒
Sarah Lean 🏴󠁧󠁒

Posted on • Originally published at techielass.com

How to Push an Empty Commit in Git

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"
Enter fullscreen mode Exit fullscreen mode

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 (0)

Update Your DEV Experience Level:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›