首页 > 解决方案 > 如何删除提交数据

问题描述

我在我的项目中添加了一个 dmg 文件,其中包含我所有的歌曲。它超过了 100MB 的 GitHub 限制。所以当我试图推动它时,它什么也做不了。但即使在我删除它之后,它仍然承认它在那里。我尝试从中制作副本,但现在当我在 Atom(GitHubs 文本编辑器)中打开项目时,Atom 会崩溃

标签: gitgithubterminalsassmacos-high-sierra

解决方案


正如@ResetACK 之前已经建议的那样,您可以重置为上一个提交,但如果您想保留该提交上的其他更改,您也可以修改您添加文件的提交。假设您当前分支的最后一个修订版是您添加文件的修订版,您可以这样做:

git rm --cached mi-dmg-file.dmg
git commit --amend --no-edit

如果它不是分支上的最新版本,可以这样做:

git checkout <the-revision-id> # checkout to the revision where we want to remove the file
git rm --cached mi-dmg-file.dmg
git commit --amend --no-edit # at this point, we diverged
git cherry-pick <the-revision-id>..the-branch #cherrypick from original revision to the tip of the branch
git branch -f the-branch # set the branch pointer to this revision now
git push *blahblah arguments* # at this point we can push the branch

现在你应该可以很好地推动了。


推荐阅读