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.
Find the commit hash of the commit you want to reset to with git log . Perform the local hard reset by running git reset --hard <commit-hash> .
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
You could delete the current branch, and create the branch again at the remote/branchname commit
git branch -D branchname git checkout remote/branchname git branch branchname
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With