我直接推送到 develop 分支没有拉取请求如何撤消它?
I pushed directly to the develop branch without pull request how do I undo it?
我正在尝试取消 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
这是我的 git develop 分支的日志
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
你可以...
git reset --hard d65fa2f
git push -f origin develop
注意:建议您在force
推送任何更改之前备份您的遥控器。此外,如果有人拉取了 James 更改的分支,他们下次尝试 pull
分支时可能会收到错误。
就我而言,可能我会这样做:
(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
= 4
和 branch_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
= 4
和 branch_name
= develop
.
我正在尝试取消 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
这是我的 git develop 分支的日志
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
你可以...
git reset --hard d65fa2f
git push -f origin develop
注意:建议您在force
推送任何更改之前备份您的遥控器。此外,如果有人拉取了 James 更改的分支,他们下次尝试 pull
分支时可能会收到错误。
就我而言,可能我会这样做:
(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
= 4
和 branch_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
= 4
和 branch_name
= develop
.