2017-05-15 36 views
0

我想清理一个私人项目,所以我可以发布它 - 从历史中删除杂项文件等。如何在root提交上运行git filter-branch?

我试图删除一个Makefile与git filter-branch。下面是我使用的命令行:

$ git filter-branch -f --index-filter 'git update-index --remove Makefile' 08a7d1..HEAD 

然而,当我运行git log -- Makefile,它显示了在根添加的Makefile文件提交,然后被删除的立即提交以下根提交。

我怎样才能让git filter-branch在根提交上运行?

回答

0

问题是您指定的提交范围(08a7d1..HEAD)中的开始落实不包含在内。所以基本上它是说“发生在08a7d1之后的所有发生,一直到HEAD”。

将提交范围传递给git filter-branch是可选的。如果你忽略它,它将在所有提交上运行,一直返回并包括根。所以:

$ git filter-branch -f --index-filter 'git update-index --remove Makefile' 

这应该做的伎俩。