【问题标题】:git: remove files of the remote repository that are been deleted in the local repositorygit:删除远程仓库的本地仓库中被删除的文件
【发布时间】:2017-06-17 07:19:40
【问题描述】:

远程存储库 (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 macos github bitbucket case-sensitive


    【解决方案1】:

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

    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>
    

    【讨论】:

    • 不是一个文件。有很多文件...而且我不确定哪些文件尚未更新。那么有什么方法可以看到差异,因为 diff 不起作用?
    • 切换到分支后可以通过git命令-git diff @{upstream}查看差异。
    • 我已经执行了git diff @{upstream}。它什么也不返回(我猜这意味着没有发现差异)
    【解决方案2】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2021-09-01
      • 2016-12-28
      • 1970-01-01
      • 2017-09-30
      • 2016-12-02
      • 2016-02-05
      • 2022-08-13
      • 2012-05-25
      • 2018-12-05
      相关资源
      最近更新 更多