Skip to main content
Everyday version control

Fix the last commit without breaking its identity

commit --amend keeps the stable change id.

Written By Dustin

Last updated About 1 month ago

tovio commit --amend

Folds your current edits into the last commit. This is the everyday โ€œI forgot a fileโ€ fix.

What happens to the message

tovio commit --amend                  # keep the existing message
tovio commit --amend -m "better message"   # rewrite it

Unlike a plain commit, --amend does not require -m and does not prompt for one: the previous message is kept when you omit it.

The part that differs from Git

Amending produces a new commit hash โ€” content addressing guarantees that. But the change id (chg:) stays the same.

That is the whole point. In Git, amending orphans anything attached to the old commit: a review, a comment, a reference from a colleague. In TOVIO those are attached to the change, and the change survived. A review of your change is still a review of your change after you amend it.

On a lane with no commits

There is no tip to fold into and no message to rewrite, so the amend is refused with TVO-OP-020 (โ€œNothing to amend on this laneโ€, exit 19). Make the first commit with a plain tovio commit -m "โ€ฆ".

Amending something already shared

Safe in a way it is not in Git. Because lanes converge rather than diverge, a colleague who already pulled does not get a โ€œdiverged historyโ€ error โ€” they get the amended change. They may get a content conflict if they had edited the same lines, which is a real disagreement rather than an artefact of the rewrite.

Undoing an amend

tovio undo

The amend is one op-log operation, so one undo puts the previous commit back.