Reset local repository branch to be just like remote repository HEAD

后端 未结 21 1891
挽巷
挽巷 2020-11-22 02:19

How do I reset my local branch to be just like the branch on the remote repository?

I did:

git reset --hard HEAD

But when I run a <

21条回答
  •  野性不改
    2020-11-22 03:01

    All of the above suggests are right, but often to really reset your project, you also need to remove even files that are in your .gitignore.

    To get the moral equivalent of erasing your project directory and re-cloning from the remote is:

    git fetch
    git reset --hard
    git clean -x -d -f
    

    Warning: git clean -x -d -f is irreversible and you may lose files and data (e.g. things you have ignored using .gitignore).

提交回复
热议问题