DEV Community

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

Posted on β€’ Originally published at techielass.com

8 3

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. 😊

Image of Datadog

Measure and Advance Your DevSecOps Maturity

In this white paper, we lay out a DevSecOps maturity model based on our experience helping thousands of organizations advance their DevSecOps practices. Learn the key competencies and practices across four distinct levels of maturity.

Get The White Paper

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay