How do I commit case-sensitive only filename changes in Git?

前端 未结 16 2314
我在风中等你
我在风中等你 2020-11-22 03:31

I have changed a few files name by de-capitalize the first letter, as in Name.jpg to name.jpg. Git does not recognize this changes and I had to de

16条回答
  •  一生所求
    2020-11-22 03:54

    I've faced this issue several times on MacOS. Git is case sensitive but Mac is only case preserving.

    Someone commit a file: Foobar.java and after a few days decides to rename it to FooBar.java. When you pull the latest code it fails with The following untracked working tree files would be overwritten by checkout...

    The only reliable way that I've seen that fixes this is:

    1. git rm Foobar.java
    2. Commit it with a message that you cannot miss git commit -m 'TEMP COMMIT!!'
    3. Pull
    4. This will pop up a conflict forcing you to merge the conflict - because your change deleted it, but the other change renamed (hence the problem) it
      1. Accept your change which is the 'deletion'
      2. git rebase --continue
    5. Now drop your workaround git rebase -i HEAD~2 and drop the TEMP COMMIT!!
    6. Confirm that the file is now called FooBar.java

提交回复
热议问题