Revert changes made by merge

前端 未结 4 611
你的背包
你的背包 2020-12-28 15:06

The developer was commiting small changes to two files. But during this commit, he had a merge conflict which deleted a lot of stuff (probably didn\'t have the last up to da

4条回答
  •  爱一瞬间的悲伤
    2020-12-28 16:02

    In short, you can do a git reset --soft where commit can be HEAD^ (previous), HEAD~2 (current-2), a SHA, etc.

    With --soft all the changes will be ready to commit, so you can actually change the commit. With --hard the changes will all be lost.

    After you altered the commit you have to force push the changes to the shared repo with git push --force.

    Note that you will need to tell the other developers that they should rebase their repos onto the shared repo. (use git pull --rebase). They could get some merge conflicts though... Please keep that in mind.

提交回复
热议问题