简体   繁体   English

git filter-branch --index-filter'git rm…'对克隆的存储库有什么影响

[英]What is the impact on cloned repositories after a git filter-branch --index-filter 'git rm …'

I have recently extracted a few subdirectories from a shared git repository with 我最近从一个共享的git存储库中提取了一些子目录,
git filter-branch --subdirectory-filter foodir -- --all

Now I have the subdirectories still left in the central shared repository and I would like to remove them. 现在,子目录仍保留在中央共享存储库中,我想将其删除。 As far as I understood from searching the web something like 据我从网上搜索了解到
git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename' HEAD
should be used to remove old Directories from the history. 应该用于从历史记录中删除旧目录。

While I believe this will work, I am now wondering if this is the best way to remove something from the history in the case where the repository is shared, as I understood that everyone with a local clone would basically have to re-clone the repository ? 虽然我相信这会行得通,但我现在想知道这是否是在共享存储库的情况下从历史记录中删除某些内容的最佳方法,因为我了解到每个拥有本地克隆的人基本上都必须重新克隆存储库?

So my ultimate question is, am I right with these assumptions or is there a way to remove Directories from multiple branches in the history without everyone having to clone the repository again? 因此,我的最终问题是,我对这些假设是否正确,还是有一种方法可以从历史记录的多个分支中删除目录,而无需每个人都再次克隆存储库?

UPDATE 更新
So I ran some tests and an currently running with this command: git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch -- Dir1 DIR2' --prune-empty --tag-name-filter cat -- --all which works but it also completely changes all SHA-1 keys of all commits, which is understandable but not desirable. 因此,我运行了一些测试,并且当前正在使用此命令运行: git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch -- Dir1 DIR2' --prune-empty --tag-name-filter cat -- --all起作用,但它也会完全更改所有提交的所有SHA-1密钥,这是可以理解的,但不是所希望的。 And it would mean everybody has to re-clone the repository and all previous links via Gitweb are going to b broken. 这意味着每个人都必须重新克隆存储库,并且之前通过Gitweb进行的所有链接都将断开。

You cannot silently alter commits if other people already have them. 如果其他人已经拥有提交,则您不能默默地更改提交。 That's how Git works and it is a feature. 这就是Git的工作方式,它是一个功能。

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

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