在我的 git 项目中,一位开发人员昨天将文件名从全部大写更改为 CamelCase。在他的功能分支中并合并到 master
我拉了遥控大师。现在在任何本地 git 操作期间,git 将文件的消息以 uppsecase(旧)显示为未跟踪。而该文件在上述文件夹中处于提交状态,而我从未在本地触及过它。
我试过的,
- 我试图用
git clean -fd
清除 untrack 树,但仍然是同样的错误。 - 我尝试使用
git rm uupercaseFilename
但命令失败,名称与任何文件都不匹配。 - 徒劳的尝试
git reset --hard HEAD
。 - 我在消息中没有看到任何文件- 最后我不得不手动删除带有骆驼案例名称的新文件
git status
nothing to commit, working tree clean
- 结帐到我的功能分支工作正常。
但是现在,如果我在我的feature-x
分支中进行任何操作,我会再次收到此错误。
我可以像上面那样通过手动删除来解决这个问题。但是想知道是否有正确的方法来处理这种情况。
以下是我运行的所有确切命令,并重命名了文件/项目/包名
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git clean -fd
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git checkout feature-x
error: The following untracked working tree files would be overwritten by checkout:
main/com/my/project/badfile//ALL_CAPS_NAME.java
Please move or remove them before you switch branches.
Aborting
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git rm main/com/my/project/badfile//ALL_CAPS_NAME.java
fatal: pathspec 'main/com/my/project/badfile//ALL_CAPS_NAME.java' did not match any files
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git rm ALL_CAPS_NAME.java
fatal: pathspec 'ALL_CAPS_NAME.java' did not match any files
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git checkout feature-x
error: The following untracked working tree files would be overwritten by checkout:
main/com/my/project/badfile//ALL_CAPS_NAME.java
Please move or remove them before you switch branches.
Aborting
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git reset --hard HEAD
HEAD is now at 5f2918e3fd Merge branch 'feature-Y' into 'master'
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git checkout feature-x
error: The following untracked working tree files would be overwritten by checkout:
main/com/my/project/badfile//ALL_CAPS_NAME.java
Please move or remove them before you switch branches.
Aborting
[gitbash] :: /c/repo/myrepo/myproject (master)
$ cd main/com/my/project/badfile/
[gitbash] :: /c/repo/myrepo/myproject/main/com/my/project/badfile/ (master)
$ ls -lrt
total 12
-rwxr-xr-x 1 gitbash 1049089 1443 Jul 29 17:44 someOtherFile.java*
drwxr-xr-x 1 gitbash 1049089 0 Aug 1 23:01 config/
-rwxr-xr-x 1 gitbash 1049089 3847 Aug 11 12:48 All_Caps_Name.java*
-rwxr-xr-x 1 gitbash 1049089 2349 Aug 11 12:48 someOtherFile2.java*
[gitbash] :: /c/repo/myrepo/myproject/main/com/my/project/badfile/ (master)
$ rm All_Caps_Name.java
[gitbash] :: /c/repo/myrepo/myproject/main/com/my/project/badfile/ (master)
$ cd -
/c/repo/myrepo/myproject
[gitbash] :: /c/repo/myrepo/myproject (master)
$ git checkout feature-x
Switched to a new branch 'feature-x'
Branch 'feature-x' set up to track remote branch 'feature-x' from 'origin'.