Reverting a series of pushed merges and commits in Git (without rewriting history)

前端 未结 4 2097
时光说笑
时光说笑 2021-02-01 16:36

Context

One of my teammates mistakenly pushed some commits to our main development branch. We\'re a small, collocated team. Our remote repository is hosted on an inter

4条回答
  •  忘掉有多难
    2021-02-01 17:35

    May I suggest that this could be considered a duplicate of this answer: Make the current git branch a master branch

    Jefromi's excellent solution was:

    [git branch better_branch ]
    git checkout better_branch
    git merge --strategy=ours master    # keep the content of this branch, but record a merge
    git checkout master
    git merge better_branch             # fast-forward master up to the merge
    

提交回复
热议问题