如何从历史记录中删除回购中不再存在的文件的提交 [英] How to remove commits from history for the files that no longer exist in the repo

查看:110
本文介绍了如何从历史记录中删除回购中不再存在的文件的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些年来,我的Github存储库包含许多项目,现在只剩下几个了.是否有可能清除我的提交历史记录,以便代替该仓库中不再存在的文件/项目的数千个提交,而只剩下与剩下的几个项目中的文件有关的一百个提交. 谢谢.

So my Github repo contains many projects over the years, and now there are only a couple remaining. Is it possible to clean my commit history so that instead of thousands of commits about files/projects that no longer exist in this repo, down to maybe a hundred commits that pertain to the files in the couple of projects remaining. Thanks.

推荐答案

您可以考虑git filter-repo ,其中将替换旧的git filter-branch或BFG .

You can consider the new git filter-repo, which will replace the old git filter-branch or BFG.

它具有

It has many usage examples, inclusing path-based filtering:

要保留除这些路径以外的所有文件,只需添加--invert-paths:

To keep all files except these paths, just add --invert-paths:

git filter-repo --path README.md --path guides/ --path tools/releases --invert-paths

这篇关于如何从历史记录中删除回购中不再存在的文件的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆