Git: renamed file manually, Git confused

前端 未结 5 1057
庸人自扰
庸人自扰 2020-12-23 09:21

I am using Git and manually renamed a file that I had added to the repository. Now, I have added the \"new\" file which I renamed to the repository but Git complains that th

5条回答
  •  伪装坚强ぢ
    2020-12-23 10:09

    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.

提交回复
热议问题