11. Commits never change
A commit cannot be edited because its name is its content; amend and every other rewrite make new commits and move the note, leaving the old commits with no note on them until cleanup.

11. Commits never change

A commit cannot be edited because its name is its content; amend and every other rewrite make new commits and move the note, leaving the old commits with no note on them until cleanup.

It makes rewriting history understandable and recovery possible.

You cannot edit a commit. Its name is its content. Change the content, and you have a different commit.

So what does amend do? Amend is the command for fixing your last commit. It makes a new commit with the same parent and your new content. Then it moves the branch note.

The old commit is still there. No note points at it any more. It is just not on the branch.

Every command that rewrites history works like this. New commits. Moved notes. The old ones stay behind.

Only much later does Git clean up commits nothing points at. Until then, nothing is lost.

Check yourself. After amend, where is the original commit?

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Connections0

Connections show where other documents or comments link to this document.

Related documents

Loading connections…