我更改了我的 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
最佳答案
你需要:
git push --force
因为您在 using git mv
之后用 --amend 重写了最后一个 SHA1 .
它不会破坏你的 repo ,除非你有其他合作者已经从你之前的提交中撤回,如“How do I push amended commit to the remote git repo?”中所述。
(在这种情况下,您将 need other options 用于发布您的固定提交)
在 OsX 上,this answer确实建议(以避免此问题):
git config --unset-all core.ignorecase
git config --system core.ignorecase false
OP kyogron reports找到了可行的解决方案:
- Create a new branch and checkout this new branch.
- Then delete the
.DS_Store
file in the directory of the corrupted directory and rename it to new name.- Then remove wrong directory in the repository (you can view them with
git ls-files
) and commit this change.- Again remove the
.DS_Store
and now rename the directory to the lower case name you want withgit mv
关于macos - mac osx 上的 git : how to push filename cases to origin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13788657/