Delete last commit in bitbucket

后端 未结 9 1334
隐瞒了意图╮
隐瞒了意图╮ 2020-12-12 10:17

I made a mistake and I don\'t know how to delete my latest push in the repository. I pull the latest updates of the app but it has conflicts and I push it to repository.

9条回答
  •  不知归路
    2020-12-12 11:07

    In the first place, if you are working with other people on the same code repository, you should not delete a commit since when you force the update on the repository it will leave the local repositories of your coworkers in an illegal state (e.g. if they made commits after the one you deleted, those commits will be invalid since they were based on a now non-existent commit).

    Said that, what you can do is revert the commit. This procedure is done differently (different commands) depending on the CVS you're using:

    On git:

    git revert 
    

    On mercurial:

    hg backout 
    

    EDIT: The revert operation creates a new commit that does the opposite than the reverted commit (e.g. if the original commit added a line, the revert commit deletes that line), effectively removing the changes of the undesired commit without rewriting the repository history.

提交回复
热议问题