【发布时间】:2018-11-08 04:24:30
【问题描述】:
我在我的项目中添加了一个 dmg 文件,其中包含我所有的歌曲。它超过了 100MB 的 GitHub 限制。所以当我试图推动它时,它什么也做不了。但即使在我删除它之后,它仍然承认它在那里。我尝试从中制作副本,但现在当我在 Atom(GitHub 文本编辑器)中打开项目时,Atom 会崩溃
【问题讨论】:
标签: git github terminal sass macos-high-sierra
我在我的项目中添加了一个 dmg 文件,其中包含我所有的歌曲。它超过了 100MB 的 GitHub 限制。所以当我试图推动它时,它什么也做不了。但即使在我删除它之后,它仍然承认它在那里。我尝试从中制作副本,但现在当我在 Atom(GitHub 文本编辑器)中打开项目时,Atom 会崩溃
【问题讨论】:
标签: git github terminal sass macos-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
现在你应该可以正常推送了。
【讨论】:
您可以使用git reset --hard <commit_hash> 恢复到之前的提交
通过使用git log 并获取commit 之后的一长串数字和字母来查找<commit_hash>。它看起来像这样:
commit 53f6a9b4219e200a6a0dcf8d367844c1f75e3517 <- this long string is what you want (not the "commit" part though)
Author: author <email@email.com>
Date: Thu May 17 16:10:39 2018 +0800
Commit message.
【讨论】: