我没有推送请求就直接推送到开发分支,如何撤消它?

时间:2019-02-05 16:34:24

标签: git repository bitbucket git-revert

我正在尝试取消james推送的所有提交,并将其提交到我的本地,然后返回到brandon推送的提交

d65fa2faf06a5c4d8d379f963feece2bf2edef98. 

我尝试做

git revert a586cc1ff0c5abf535a4d0873c458a812dca28dd..1dcc0e8adc5433a5b092e3b813496ac52de7aa43

-但由于某些未知原因,它引发了此错误

    hint: Waiting for your editor to close the file... error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

,最后只恢复1dcc0e8adc5433a5b092e3b813496ac52de7aa43

这是我的develop分支的git日志

commit 1dcc0e8adc5433a5b092e3b813496ac52de7aa43 (origin/develop, feat_SS_250.fixes)
Author: <james@ueharanoMacBook-Pro.local>
Date:   Tue Feb 5 17:50:20 2019 +0900

    schema added

commit fee01a2dcf3432b7da6e9e6b1ff030ad288d919d
Author: <james@ueharanoMacBook-Pro.local>
Date:   Tue Feb 5 17:48:49 2019 +0900

    rebase

commit 7f226d84029e608721417b8e99be1a88c6ae3a84
Author: <james@ueharanoMacBook-Pro.local>
Date:   Tue Feb 5 16:03:07 2019 +0900

    initial commit

commit a586cc1ff0c5abf535a4d0873c458a812dca28dd
Author: <james@ueharanoMacBook-Pro.local>
Date:   Thu Jan 24 11:42:08 2019 +0900

    added login.php

commit d65fa2faf06a5c4d8d379f963feece2bf2edef98
Author: brandon <brandon@xxxx.co.jp>
Date:   Tue Feb 5 14:52:04 2019 +0900

    feat: fp 50

commit 9988b6587f9e2fa77d86e9e1f856bf57e667daca
Author: brandon <brandon@xxxx.co.jp>
Date:   Tue Feb 5 14:25:51 2019 +0900

    feat: contract 50

2 个答案:

答案 0 :(得分:1)

您可以...

git reset --hard d65fa2f
git push -f origin develop

注意:建议您在force进行任何更改之前先备份遥控器。另外,如果有人拉了拥有James更改的分支,则下次尝试pull分支时,他们会收到错误消息。

答案 1 :(得分:0)

就我而言,可能是这样:

(01)重置一些最近的提交,并将提交保持在暂存状态:

$ git reset --soft HEAD~<num_of_commit_from_HEAD>
$ git status
$ git log
$ git push -f origin <branch_name>

在这里,您的情况是num_of_commit_from_HEAD = 4branch_name = develop

(02)重置一些最近的提交并删除提交:

$ git reset --hard HEAD~<num_of_commit_from_HEAD>
$ git status
$ git log
$ git push -f origin <branch_name>

在这里,您的情况是num_of_commit_from_HEAD = 4branch_name = develop

相关问题