Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Amending a Past Commit

You realize the login form is missing a CSRF token. You fix src/auth.rs and check the status:

╭─ zz [local changes]
│    M src/auth.rs
│
│╭─ fa [feature-auth]
│●   c2 add password validation
│●   d0 add login form
├╯
│
● a1b2c3d (upstream) [origin/main] Latest upstream commit

You want to amend this change into the original “add login form” commit (d0), not create a new commit.

$ git loom fold src/auth.rs d0

This stages src/auth.rs and amends it into commit d0. The branch topology stays the same — the commit just gains the new changes.

If you’ve already staged the files you want to amend, you can use the single-argument form:

$ git add src/auth.rs
$ git loom fold d0

This folds only the staged changes — any unstaged modifications to the same files are preserved.

To amend all working tree changes into a commit at once:

$ git loom fold zz d0

Tip

Use git loom status -f d0 to see which files are in a commit before and after amending.

See also: fold reference