问题描述
我试图从我的git存储库中分离一个子项目。
但不像
我没有它在它自己的子目录中(并且将它移入并执行上述操作只会在移动后产生历史记录)。
我克隆了我想从中分离出子项目的分支到它自己的存储库中,并删除了子项目没有使用的所有东西,所以基本上我可以使用它作为我的子项目的存储库。
现在我想摆脱不再存在于此存储库中的所有文件的历史记录,以便只保留文件的历史记录,使其进入后代。
我认为git-filter-branch一定是可以的,但我无法弄清楚
非常感谢提前
这将删除 file_to_remove
:
$ b $ pre $ git filter-branch --index-filter'git rm --cached --ignore-unmatch file_to_remove'--prune-empty - --all
I'm trying to split a subproject off of my git repository.However unlike inDetach (move) subdirectory into separate Git repositoryI don't have it in it's own subdirectory (and moving it in and doing the above only yields the history after the move).
I've cloned the branch from which I want to split off the subproject into it's own repository and removed everything that isn't used by the subproject, so basically I could use this as the repository of my subproject.
Now I want to get rid of the history of all files that are no longer in this repository so as to only keep the file history for the files that made it into the offspring.
I think it must be possible with git-filter-branch but I can't figure out how
Many thanks in advance
Here are some instructions to do what you want.
This will remove file_to_remove
:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch file_to_remove' --prune-empty -- --all
这篇关于从git历史中删除已删除的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!