英文:
How to remove file from git history without diverging the history?
问题
开发者A(原作者)创建了一个仓库。他在初始提交中包含了一个大的二进制文件。
开发者B(我)创建了一个分支并提交了删除该二进制文件的更改(但它仍然保留在历史记录中)。之后,B对该分支进行了更多的更改,而A的仓库保持不变。
B如何在不创建完全不同的提交历史记录与A的仓库的情况下删除该文件(我可以接受几个不同的提交历史记录)?或者至少在克隆仓库时禁用对该二进制文件的自动克隆。
我尝试过git filter-branch
、git-filter-repo
和git rebase -i
。它们都会创建不同的提交历史记录。
英文:
Let's say developer A (original author) creates a repository. He makes an initial commit in which he includes big binary file.
Developer B (me) creates a fork and commits removal of that binary (it still stays in history). After that B makes more changes to the fork, while A's repo remains untouched.
How can B remove the file from history without creating completely diverging histories with A's repo (I'm ok with several diverging commits)? Or at least disable automatic cloning of that binary when cloning the repo.
I've tried git filter-branch
, git-filter-repo
and git rebase -i
. They all create diverging histories.
答案1
得分: 2
由于Git的设计和操作原则,这简单不可能。具有不同历史记录的两个存储库不会在以后收敛到相同的提交哈希集。
英文:
It's simply not possible, due to the design and operating principles of Git. Two repos with different things in their history are not going to converge to the same set of commit hashes later on.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论