Git 从历史记录中删除大型二进制文件 - 但保留标签
该问题已在 Stack Overflow 上发布过多次,但没有一个答案包含如果您有标签该怎么办。
我的问题是,我使用
git filter-branch -f --index-filter 'git rm -rf --ignore-unmatch audio_samples' HEAD
这似乎工作得很好,但我的存储库并没有变小!即使我尝试了
git clone file:///path/to/project1 project1clone
它仍然是相同的大小。
只有当我检查标签时,我才意识到二进制文件仍然被引用。好的,所以我删除了所有标签,现在新的克隆存储库更小了。但是,我需要我的标签,因此我恢复到项目目录的备份版本,现在又回到了第一步。如何使我的标签不引用大型二进制文件的提交,但仍然指向它们应该在的位置?
This has been posted many times on Stack Overflow, but none of the answers include what to do if you have tags.
My problem is that I cleared out a binary file from every branch using
git filter-branch -f --index-filter 'git rm -rf --ignore-unmatch audio_samples' HEAD
This seemed to work nicely but my repository wasn't getting any smaller! Even when I tried
git clone file:///path/to/project1 project1clone
It was still the same size.
It was only when I checked out a tag, I realized the binary file was still being referenced. OK, so I removed all my tags, and now a new cloned repo is smaller. However, I need my tags, so I reverted to a backed up version of my project directory, and am now back at square one. How do make it so that my tags aren't referencing a commit with the large binary file, but still pointing to where they should be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的命令只是重写
HEAD
。尝试使用-- --all
而不是HEAD
。Your command there is only rewriting
HEAD
. Try using-- --all
instead ofHEAD
.