如何从github/gitlab中的所有分支中删除特定对象

发布于 2025-01-26 18:52:57 字数 88 浏览 5 评论 0原文

假设我有100个分支,每个分支都有file1,file2 ..... file10。现在,我想从所有100个分支中删除File2。我该怎么办将其从所有分支中删除?

Lets assume that I have 100 branches and each branches have file1,file2.....file10. Now I want to delete file2 from all of 100 branches. What should I do to delete that from all branches?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞旧 2025-02-02 18:52:57

您可以使用 git filter-repo(基于Python ,be 首先安装了) git filter-branch-branch或bfg 在git 2.22或更多之后被淘汰)

=“ https://htmlpreview.github.io/?https://github.com/newren/newren/git-filter-repo/blob/blob/blob/docs/html/git-filter-repo.htmlleter-repo.htmlllllllltmllltmllltering_filtering_filtering_filter_on_on_on_on_on_pathssssse_eleso_also_also see_aleorlobly = “>基于路径的过滤

git filter-repo --path file2 --invert-path

它的男人页面提到,关于git filter-branch

尽管使用了- 所有- tag-name-filter,以及filter-branch的manpage,声称克隆足以摆脱旧对象,删除其他标签并执行另一个gc的额外步骤仍然需要清理旧对象并避免在推开某个地方之前混合新的和旧的历史。

git filter-repo will 迫使您先进行备份,然后继续更改您要过滤的本地存储库的历史。

检查是否已经清理了所有分支,在所有分支中寻找file2

git log --all -- file2

You can use git filter-repo (python-based, to be installed first) for that (since git filter-branch or BFG are obsolete after Git 2.22 or more)

Use a path-based filtering:

git filter-repo --path file2 --invert-path

Its man page mentions, about git filter-branch:

Despite the use of --all and --tag-name-filter, and filter-branch's manpage claiming that a clone is enough to get rid of old objects, the extra steps to delete the other tags and do another gc are still required to clean out the old objects and avoid mixing new and old history before pushing somewhere.

git filter-repo will force you to make a backup first, then proceed to change the history of the local repository you are filtering.
Check that all branches have been cleaned up, by looking for file2 in all branches.

git log --all -- file2
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文