Reset local repo to be exactly the same as remote repo

How do I reset my local git repo to be exactly the same as the remote repo?

I've tried:

git reset --hard HEAD^

But now git status says I have diverging commits. I basically want to just wipe anything I've got locally and get the exact remote repo on my local machine.


git reset --hard HEAD^ will only reset your working copy to the previous (parent) commit. Instead, you want to run

git reset --hard origin/master

Assuming remote is origin and the branch you want to reset to is master


您可以删除当前分支,并在远程/ branchname提交中再次创建分支

git branch -D branchname
git checkout remote/branchname
git branch branchname
链接地址: http://www.djcxy.com/p/26254.html

上一篇: 我如何从stdin建立一个tar?

下一篇: 重置本地回购与远程回购完全相同