Git: renamed file manually, Git confused
There is no problem. Simply git rm old
or even git add -A
and it will realize that it is a rename. Git will see the delete plus the add with same content as a rename.
You don't need to undo, unstage, use git mv
etc. git mv old new
is only a short hand for mv old new; git rm old; git add new
.
First, cancel your staged add for the manually moved file:
$ git reset path/to/newfile
$ mv path/to/newfile path/to/oldfile
Then, use Git to move the file:
$ git mv path/to/oldfile path/to/newfile
Of course, if you already committed the manual move, you may want to reset to the revision before the move instead, and then simply git mv
from there.
Try this:
mv new old
git rm new
git mv old new