繁体   English   中英

git:删除远程存储库中已在本地存储库中删除的文件

[英]git: remove files of the remote repository that are been deleted in the local repository

远程存储库(bitbucket)中存在一些文件。 但是,这些文件在本地存储库中不再存在。

我猜它与以下命令有关:

git config core.ignorecase false

在意识到文件在我的计算机(OSX)中是正确的但在Git存储库中是错误的之后,我执行了该命令(它们在本地存储库中为小写,而在远程存储库中为大写)。 然后我执行了:

git add . && git commit -m "comment"
git push origin master

不幸的是,存储库的大写文件没有更改为小写。 相反,存储库保留了大小写文件的重复。

我已经执行了以下命令:

git diff master origin (it does not show anything, I guess because it does not detect any change).
git commit -a (no effect)
git add -u (no effect)

从远程更新本地存储库,删除大写的文件(假设要在远程存储库中保留小写的文件),从工作树和索引中删除文件,提交并推送到远程,如下所示:

git pull origin <remote> --rebase
rm <file-with-upper-case> //skip if file does not exist in local
git rm -f <file-with-upper-case>
git commit -m "Deleted Upper Case File"
git push origin <remote>

这是我为解决此问题所做的事情:

我下载了几个Git GUI。 GitUp GUI显示了重复的文件,我不知道为什么:

GitUp屏幕截图

我意识到只有两个文件夹重复。 因此解决方案是:

  • 将两个文件夹都移到桌面上(我在OSX上使用Finder来完成;如果使用Windows,则可以使用其文件资源管理器或任何其他GUI)。
  • 使用Git添加和提交
  • 将两个文件夹都移到其原始位置
  • 再次添加和提交与Git

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM