【问题标题】:How do You Delete Commit Data [duplicate]你如何删除提交数据[重复]
【发布时间】:2018-11-08 04:24:30
【问题描述】:

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

【问题讨论】:

    标签: git github terminal sass macos-high-sierra


    【解决方案1】:

    正如@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
    

    现在你应该可以正常推送了。

    【讨论】:

    • 不幸的是,这不是最近的提交
    • @Maya 如果不是最近的提交,还是有可能的,只是需要多走几步。我调整了食谱。
    • 谢谢!这将有很大帮助
    【解决方案2】:

    您可以使用git reset --hard &lt;commit_hash&gt; 恢复到之前的提交

    通过使用git log 并获取commit 之后的一长串数字和字母来查找&lt;commit_hash&gt;。它看起来像这样:

    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.
    

    【讨论】:

    • 谢谢!这似乎可行,但即使我没有按 Enter 键,我也会在 \n 附近出现“解析错误”
    猜你喜欢
    • 2013-08-11
    • 2012-10-09
    • 1970-01-01
    • 2012-06-04
    • 2012-07-01
    • 1970-01-01
    • 2012-01-01
    • 2011-11-01
    • 1970-01-01
    相关资源
    最近更新 更多