DEV Community

Cover image for How to do empty commit in git and why?
Ashutosh
Ashutosh

Posted on • Edited on • Originally published at ashutosh.website

3

How to do empty commit in git and why?

Did you know you can make empty commits in git?

Have you ever needed to trigger a CI build but couldn't because manual re-trigger was not an option?
If so, you might be tempted to make a meaningless change to your source file only to make a git commit just to re-trigger the CI pipeline.

What if I told you there was a better way to do it? 🧐

Empty commit

Yes! You can make a git commit without making any changes to your source file(s) whatsoever. For example:

git commit --allow-empty -m "Trigger CI build"
Enter fullscreen mode Exit fullscreen mode

I hope you find this tip interesting and helpful.
If you did, please give it a like and share it with someone who might benefit from it.

My name is Ashutosh, and I work as a software engineer. I love to share my learning with the community.
You can connect with me on LinkedIn and follow me on Twitter.

Top comments (1)

Collapse
 
anshuman_bhardwaj profile image
Anshuman Bhardwaj

Thanks, Ashutosh. I learned something new today.

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay