FG
💻 Software

How to amend the last commit to un-add a file?

Fresh7 days ago
Mar 15, 2026142175 views
Confidence Score1%
1%

Problem

I have modified two files , in the last commit. But file should not be commited, what's the workflow to amend this?

Error Output

a

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to amend the last commit to un-add a file?

Low Risk

Update (couple of years later) Jan Hudec It's trivial to remove it from index only. True: you can reset a file to its index content easily enough, as the more recent answer (written by Matt Connolly) suggests: allows the file to access its content in the previous commit before the last one. Then you can , as I originally wrote below. With Git 2.23 (August 2019), you might use the new command shorter: Again, you then can , as I originally wrote below. Original answer (January 2011) If this is yo…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment