我在包含数百个其他文件的 Git 存储库中编写了一个脚本(假设为 make.bat
)。 make.bat
的提交始终只涉及文件 make.bat
,但与其他文件的提交一起。
原始存储库(包含 make.bat
以及数百个其他文件,8 次提交):
commit A - initial commit
commit B
commit C - add make.bat
commit D
commit E - update make.bat
commit F
commit G - update make.bat
commit H
如何创建另一个只有文件 make.bat
及其所有历史记录的存储库?
新仓库(仅包含一个文件 make.bat
,3 次提交):
commit C - add make.bat
commit E - update make.bat
commit G - update make.bat
答案 0 :(得分:2)
如果在任何 make.bat
次提交中都没有更改任何文件是绝对正确的,那么只需复制您的项目文件夹,然后说
git rebase -i --root
在编辑器中,删除表示不是 make.bat
提交的所有行。保存并退出编辑器。
现在您有一个完全包含 make.bat
历史的存储库。