Home » Git » Pushing empty commits to remote

Pushing empty commits to remote

Posted by: admin November 15, 2021 Leave a comment


I have pushed one commit to remote but now I realized that the commit message is not correct. I would like to change the commit message but AFAIK it is not possible. So i decided to create empty commit with correct message:

git commit --allow-empty

Are there any disadvantages/consequences of pushing empty commits? Is there any problem I might face in future because of this empty commit??

git commit --allow-empty -m "Trigger Build"


You won’t face any terrible consequence, just the history will look kind of confusing.

You could change the commit message by doing

git commit --amend
git push --force-with-lease # (as opposed to --force, it doesn't overwrite others' work)

BUT this will override the remote history with yours, meaning that if anybody pulled that repo in the meanwhile, this person is going to be very mad at you…

Just do it if you are the only person accessing the repo.


pushing commits, whether empty or not, causes eventual git hooks to be triggered. This can do either nothing or have world shattering consequences.


Is there any disadvantages/consequences of pushing empty commits?

Aside from the extreme confusion someone might get as to why there’s a bunch of commits with no content in them on master, not really.

You can change the commit that you pushed to remote, but the sha1 of the commit (basically it’s id number) will change permanently, which alters the source tree — You’d then have to do a git push -f back to remote.


As long as you clearly reference the other commit from the empty commit it should be fine. Something like:

Commit message errata for [commit sha1]

[new commit message]

As others have pointed out, this is often preferable to force pushing a corrected commit.


As for confusing history I have a proposal for eventually making life of future archeologists easier.

git commit --allow-empty -m "message for commit DEADBEF was wrong. Correct Msg: ..."

where DEADBEF stands for the commit hash (SHA) of the commit with the wrong message.

Or if empty commit is not possible/allowed one could create a document


add/commit it and push it.

BTW: Cant resist to let on that git history is very often confusing anyway 🙂


What about this;

 git commit --allow-empty-message -m ''