Git Reset - remotes/origin/master not in sync with local master
-
26-05-2021 - |
Question
On one of my repositories the local master is ahead of the remotes/origin/master
* - master (123)
* -
* - remotes/origin/master (456)
All my other local repos (based on the same remote repository) have the remote/origin/master at the same commit hash (123). How do I reset the local repo so the remotes/origin/master is back in sync?
Solution
what happens if you do git fetch origin
?
or if you have manually broken something with the remote branch you could always:
git remote -v # note url
git remote rm origin
git remote add origin <url>
OTHER TIPS
As Pierre pointed out you will "lose" your local modifications (if you have commited your changes they are still there as loose objects). So you might want to create a temporary branch before resetting
This will reset your local branch so it points to the same commit as the remote.
git fetch origin
git checkout -b old_master // optional
git reset --hard origin/master
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow