Throw away local commits in Git

前端 未结 20 1752
遥遥无期
遥遥无期 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 04:03

    For those interested in the Visual Studio solution, here is the drill:

    1. In the Team Explorer window, connect to the target repo.
    2. Then from Branches, right-click the branch of interest and select View history.
    3. Right-click a commit in the History window and choose Reset -> Delete changes (--hard).

    That will throw away your local commits and reset the state of your repo to the selected commit. I.e. Your changes after you pulled the repo will be lost.

提交回复
热议问题