我更改了git存储库中某些目录的大小写。 然后我推了他们,注意到没有更新的情况。
然后我发现了这个问题: git mv and only change case of directory
我已按照建议使用:
git add -A
git commit --amend -m 'updated cases'
git push origin
但git服务器返回成功而不是成功:
To git@github.com:kyogron/example.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:kyogron/example.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
我现在可以做些什么来更新案例而不会在我的git仓库中破坏更多?
此致
伯度
PS:为了避免将来出现此问题,您可以使用:
git config core.ignorecase false
答案 0 :(得分:6)
你需要:
git push --force
因为您在using git mv
之后使用--amend重写了最后一个SHA1。
除非您有其他协作者已经从之前的提交中撤消,否则不会破坏您的回购,如“How do I push amended commit to the remote git repo?”中所述。
(在这种情况下,您将[{3}}发布您的固定提交)
在OsX上,need other options建议(避免此问题):
git config --unset-all core.ignorecase
git config --system core.ignorecase false
this answer OP kyogron找到了可行的解决方案:
- 创建一个新分支并签出此新分支。
- 然后删除损坏目录的目录中的
.DS_Store
文件,并将其重命名为新名称。- 然后删除存储库中的错误目录(您可以使用
git ls-files
查看它们)并提交此更改。- 再次删除
将目录重命名为所需的小写名称.DS_Store
,现在使用git mv