如何从历史记录中删除回购中不再存在的文件的提交 [英] How to remove commits from history for the files that no longer exist in the repo
问题描述
这些年来,我的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屋!