I know how to
but what I want is to exclude the renamed file from last git commit, but retain anything else (as git mv
get into my commit unintentionally).
How can I do that?
(Seems I can only revert everything or not at all...)
You can search the internet for "git how can I change my latest commit content", you will find documentation pages such as :
One generic way to "change the latest commit" is to edit files and git add
them as you want, then run git commit --amend
.
This works for any kind of modifications: the commit will simply contain the new content you git add
ed.
For example:
git mv old.txt new.txt
:git mv new.txt old.txt
git commit --amend
old.txt
but not add new.txt
in the commit:git rm --cached new.txt # --cached will make git keep the file on disk
git commit --amend
# edit file foo.txt ...
git add foo.txt
git commit --amend
etc ...