簡體   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