git commit --amend , like git rebase , will create a new commit object. This object is based on a pre-existing commit, but it is still a new commit and completely replaces the old one.
Looking at the story, it might look like this:
master ↓ * --- * --- * --- A
Given that A is the original latch. If we change this commit now, we get the following result:
* --- * --- * --- A \ --- A' ↑ master
So, we get another A' commit object with a different hash, and the branch we were on (here: master) is updated to indicate this.
Now, if we add a remote repository to this view, and we pressed A earlier on the remote, then it looks like this:
origin/master ↓ * --- * --- * --- A \ --- A' ↑ master
So the remote object still points to the original commit A , but our local branch points to the modified A' . This is a problem because we cannot press A' and make origin/master point in A A' , as this will remove the already committed commit A from the history.
We can force push with git push --force to force Git to update the remote branch and really remove A from the story. It is important to note that this will break any story that has already pulled A out of the console. If any other developer has A and now the deleted points in A' , then they have a conflict that they must correct manually. This often hurts, so there is a rule that you should always follow:
Never reinstall (or modify) previously published commits.
A better alternative is to add a new commit B that just makes corrections on A :
origin/master ↓ * --- * --- * --- A --- B ↑ master
Thus, the already published story is still compatible with the new story, so we can press B on the remote computer without conflict, and everyone is happy.