Search code examples
gitrepositorybitbucketgit-revert

I pushed directly to the develop branch without pull request how do I undo it?


I am trying to cancel all the commit pushed by james plus getting his commits on my local and go back to the commit pushed by brandon which is

d65fa2faf06a5c4d8d379f963feece2bf2edef98. 

I tried doing

git revert a586cc1ff0c5abf535a4d0873c458a812dca28dd..1dcc0e8adc5433a5b092e3b813496ac52de7aa43

-- but for some unknown reasons it throws me this error

    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.

and at the end it only reverts 1dcc0e8adc5433a5b092e3b813496ac52de7aa43

here is my git log of the develop branch

commit 1dcc0e8adc5433a5b092e3b813496ac52de7aa43 (origin/develop, feat_SS_250.fixes)
Author: <[email protected]>
Date:   Tue Feb 5 17:50:20 2019 +0900

    schema added

commit fee01a2dcf3432b7da6e9e6b1ff030ad288d919d
Author: <[email protected]>
Date:   Tue Feb 5 17:48:49 2019 +0900

    rebase

commit 7f226d84029e608721417b8e99be1a88c6ae3a84
Author: <[email protected]>
Date:   Tue Feb 5 16:03:07 2019 +0900

    initial commit

commit a586cc1ff0c5abf535a4d0873c458a812dca28dd
Author: <[email protected]>
Date:   Thu Jan 24 11:42:08 2019 +0900

    added login.php

commit d65fa2faf06a5c4d8d379f963feece2bf2edef98
Author: brandon <[email protected]>
Date:   Tue Feb 5 14:52:04 2019 +0900

    feat: fp 50

commit 9988b6587f9e2fa77d86e9e1f856bf57e667daca
Author: brandon <[email protected]>
Date:   Tue Feb 5 14:25:51 2019 +0900

    feat: contract 50

Solution

  • You can ...

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

    Note: would suggest that you take a backup of your remote before force pushing any changes. Also, if someone has pulled the branch which has James changes they are subject to receive errors next time they try to pull the branch.