Throw away local commits in Git

前端 未结 20 1693
遥遥无期
遥遥无期 2020-12-02 03:08

Due to some bad cherry-picking, my local Git repository is currently five commits ahead of the origin, and not in a good state. I want to get rid of all these commits and st

20条回答
  •  伪装坚强ぢ
    2020-12-02 03:48

    I had a situation where I wanted to remove a commit that wasn't pushed, but the commit was before another one. To do so, I've used the following command

    git rebase -i HEAD~2 -> it will rebase the last two commits

    And I used 'drop' for the commit signature that I wanted to remove.

提交回复
热议问题