macos - mac osx 上的 git : how to push filename cases to origin?

标签 macos git github filenames hfs+

我更改了我的 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 with git mv

关于macos - mac osx 上的 git : how to push filename cases to origin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13788657/

相关文章:

git - 我可以用 git 做一个目录列表,显示最新的提交日期吗

GIT 在我的案例中添加还原(保留更改)

css - Github 不读取网站中嵌入的字体

Mac OS X 终端中的 Python unicode

git - Git 子模块是否是一个不强制库用户下载其测试的好主意?

python - macOS 上使用 tkinter 移动对象时出现 RecursionError

git - "git reset --hard HEAD"之后的 "git commit --amend"

javascript - 我可以直接从 GitHub 运行 HTML 文件,而不仅仅是查看它们的源代码吗?

iphone - 为什么不需要在 NSURLConnectionDelegate 协议(protocol)中声明 NSURLConnection 委托(delegate)方法

java - Java 中的窗口拖动事件