Why can't I push an empty commit?

The issue is not that you are pushing an empty commit.
It is about pushing a different commit (one with a different SHA1) than the one commit already pushed.
That is what git commit --amend does: it modified the last commit, it doesn't create a new one.

That means you are pushing a different history than the one others might have already cloned.
If you are sure that won't be a problem, you need to force the push:

git push -f origin master

Should you have done:

git commit --allow-empty

You would have created a new (empty) commit, which you could have pushed without any issue.


If you want to create pull request on Github. You can:

git commit --allow-empty -m "make pull request"

Then create pull request with no change.


To clarify the accepted answer, since I don't have enough reputation to comment:

When you use

git commit --amend

it does create a new commit. However, it doesn't append it to the current commit, it appends it to the parent of the current commit. Visually, it would look like a fork.

  O (old commit)
 /
O-O (amended commit)

Git interprets this as a divergence from the remote. That is why it will not let you push it without forcing.

Tags:

Git