How to revert multiple git commits?

后端 未结 13 2403
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 07:36

I have a git repository that looks like this:

A <- B <- C <- D <- HEAD

I want the head of the branch to point to A, i.e. I want B

13条回答
  •  鱼传尺愫
    2020-11-22 08:06

    Clean way which I found useful

    git revert --no-commit HEAD~3..
    

    This command reverts last 3 commits with only one commit.

    Also doesn't rewrite history.

    The .. helps create a range. Meaning HEAD~3.. is the same as HEAD~3..HEAD

提交回复
热议问题