In an earlier commit, I need to undo all changes to certain files, but keep the changes of other files.
What I'm doing:
git rebase -i [sha-ref]
git-rebase-todo
changing pick
to edit
for the affected commit.My files are now all in the state they were committed in [sha-ref]
.
I tried git restore [file-name]
, but it does nothing. git restore --staged [file-name]
obviously doesn't do anything, because the changes are not staged.
How can I undo the changes just for one file ?
I finally found it:
git checkout [sha-ref]~ [file-name]
git commit --amend
git rebase --continue