Throw away local commits in Git

前端 未结 20 1747
遥遥无期
遥遥无期 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:00

    To see/get the SHA-1 id of the commit you want to come back too

    gitk --all
    

    To roll back to that commit

    git reset --hard sha1_id
    

    !Note. All the commits that were made after that commit will be deleted (and all your modification to the project). So first better clone the project to another branch or copy to another directory.

提交回复
热议问题