TILgit

#TIL 34 - Remove some files from last commit

Dec 5, 2022 · Dung Huynh

What

Undo the last commit but keep changes as staged modifications.

Why

Accidentally committed files you want to exclude, or need to amend the commit.

How

git reset --soft HEAD~1

Files return to staging area. Remove unwanted files with git reset <files>, then re-commit.