Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 删除不是头的远程提交_Git_Git Commit_Git Remote_Git Reset_Git Revert - Fatal编程技术网

Git 删除不是头的远程提交

Git 删除不是头的远程提交,git,git-commit,git-remote,git-reset,git-revert,Git,Git Commit,Git Remote,Git Reset,Git Revert,我的处境很棘手。我需要删除并重新提交一些我已经推送到github remote repo的提交。但这些承诺已经不再是头了(人们把他们的承诺推到了头上) 我知道我可以恢复提交,因此保留提交历史记录。但要求是让错误的承诺消失 因此: D你不能那样做 问题是commitD中有commitC的ID。任何你为了摆脱B和C而做的事情,如果真的有效的话,也会摆脱commitD 您可以将提交D复制到一个新的D',这与D非常相似,但是: 删除B和C中的更改,以及 使用A作为其父提交 但是如果你这样做了,你必须与现

我的处境很棘手。我需要删除并重新提交一些我已经推送到github remote repo的提交。但这些承诺已经不再是头了(人们把他们的承诺推到了头上)

我知道我可以恢复提交,因此保留提交历史记录。但要求是让错误的承诺消失

因此:

D你不能那样做

问题是commit
D
中有commit
C
的ID。任何你为了摆脱
B
C
而做的事情,如果真的有效的话,也会摆脱commit
D

您可以将提交
D
复制到一个新的
D'
,这与
D
非常相似,但是:

  • 删除
    B
    C
    中的更改,以及
  • 使用
    A
    作为其父提交
  • 但是如果你这样做了,你必须与现在也有提交
    D
    的其他人协调,尤其是编写它的人,并让所有人切换到新的
    D'
    副本,该副本将
    A
    作为其父副本

    通常这是不值得做的。要让47个人撤销并重做他们所有的工作,仅仅为了补偿你之前犯下的错误,这太难了。接受错误吧

    如果这个错误比让其他人因为你让他们重新做他们所有的工作而对你生气更糟糕,请参阅

    D <- other people's commit
    |
    C <- B and C are wrong commits! They need to be removed
    | <- The changes that should be preserved from B and C will be
    B <- committed on top of D
    |
    A <- this was the initial state