英文:
How do I merge two separate commits so that a file is completely removed in IntelliJ/Git?
问题
在我的项目中,我有一个文件超过 100 MB(这意味着我无法将其上传到 Github)。我提交了我的更改,包括添加了该文件。然后我意识到这个文件是不必要的,于是我将其删除。然而,当我再次提交时,由于那个被删除的文件超过了 100 MB 的限制,我仍然无法推送我的提交,即使我在随后的提交中将其删除。有没有办法合并这两个提交,使得这个文件从未存在,从而不尝试将其推送到 Github?
我知道我可以使用类似 git-lfs 的东西,但我只是想知道是否有一种更快速的方法来解决这种问题。
英文:
In my project, I had one file which is over 100 MB (which means I am unable to upload it to Github). I committed my changes, including the addition of the file. I then realized that the file was unneeded, and I removed it. However, when I committed again, I was still unable to push my commits because of that one file which was removed being over the 100 MB limit, even though I removed it in the subsequent commit. Is there a way to merge these two commits so that the file never existed so that it doesn't try to push it to Github?
I know I can use something like git-lfs, but I was just curious to see if there was a faster way to fix this kind of problem.
答案1
得分: 1
你可以从一个没有那个100MB文件的提交开始使用 git rebase -i
,然后编辑那些错误地将这个文件添加到你的历史记录中的提交。
英文:
You can use git rebase -i
starting from a commit which doesn't have the 100MB file, and edit the commits that wrongly add this file in your history.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论