Git 将目录重命名为另一个相同名称的情况显示包含始终修改的文件
将目录 TestDirectory 重命名为小写(testdirectory)后,它的所有文件(a.html 和 b.html)都显示为已修改,甚至 git reset --hard 也不会重置工作树。
Git 总是说:
# modified: TestDirectory/a.html
# modified: TestDirectory/b.html
没有任何方法可以将工作树重置为未修改的状态,以下命令都没有帮助:
git reset --hard
git checkout -- TestDirectory/a.html
我不明白为什么会发生这种情况以及我能做什么。这是 git bug 吗?
重命名不是我添加的,而是另一个 git 用户添加的。
git 版本 1.6.4
我运行的是 Mac OS X 10.6
After the directory TestDirectory was renamed to lower case (testdirectory) all it's files (a.html and b.html) are shown as modified and even git reset --hard doesn't reset the working tree.
Git always says:
# modified: TestDirectory/a.html
# modified: TestDirectory/b.html
Nothing works to reset the working tree to unmodified state, none of following commands help:
git reset --hard
git checkout -- TestDirectory/a.html
I don't understand why this happens and what I can do. Is it git bug?
The rename wasn't added by me but another git user.
git version 1.6.4
I am running Mac OS X 10.6
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
玩了大约一个小时后,我的解决方案是手动删除 testdirectory/a.html 和 testdirectory/b.html - 之后 git 将它们报告为“已删除”(我实际上不想删除它们),但它给了我做的能力git pull 并在问题被其他用户解决后获取更改。
简短步骤:
注意:以前 git pull 无法完成,导致合并冲突错误。
我不清楚发生了什么,但它解决了我的案子。在我看来,Git 仍然像 Perl 一样相当复杂,命令主要反映 git 的内部结构而不是用户意图:-)
After playing about an hour my solution was to delete testdirectory/a.html and testdirectory/b.html manually - after that git reported them as "deleted" (I don't want to delete them actually) but it gave me ability to do git pull and get changes when problem was fixed by another user.
Shortly steps:
Note: previously git pull couldn't be done cause merge conflict error.
I didn't clearly understand what's happend but it solved my case. In my opinion Git is still quite complicated like Perl and commands mostly reflects the internals of git rather than user intentions :-)
您可以检查 git 是否重写了行结尾(git diff 显示被自身替换的文件,仅具有不同的行结尾)。在这种情况下,您应该查看 什么是最好的 CRLF(回车回车、换行)Git 的处理策略?。
You could check if git rewrote line endings (git diff shows the file replaced by itself, only with different line endings). When this is the case, you should look at What's the best CRLF (carriage return, line feed) handling strategy with Git?.