git checkout is not removing files that it should

后端 未结 4 718
忘了有多久
忘了有多久 2021-02-14 07:45

Using a public repo, I want to get my master branch back to a certain commit from the past. I have reviewed the options and the best thing for me looks to be a simple checkout t

4条回答
  •  难免孤独
    2021-02-14 07:55

    Do you want to roll back your repo to that state? Or you just want your local repo to look like that?

    See https://git-scm.com/docs/git-reset for git reset.

    CASE 1: if you do

    git reset --hard [commit hash]
    

    It will make your local code and local history be just like it was at that commit. But then if you wanted to push this to someone else who has the new history, it would fail.

    CASE 2: if you do

    git reset --soft [commit hash]
    

    It will make your local files changed to be like they were then, but leave your history etc. the same.

    I found answer here. Also you can see related answer here.

提交回复
热议问题