-
Notifications
You must be signed in to change notification settings - Fork 23
Git Extreme Actions
I get asked a lot of git questions. Here's where I keep the more extreme answers
(Note: We use main in place of master, as this is the github default as of October 1, 2020.)
Okay, I now know my main branch was supposed to be used only to track the upstream project. How do I reset it to be in sync with upstream?
Here we assume you already have configured your upstream remote correctly.
git remote update
# the double hyphen ensures that upstream/main is
# considered as a revision and not confused as a path
git reset --hard upstream/main --
Then push this new branch-head to your origin repository, ignoring the fact that it won't be a fast-forward:
git push origin +main
ref: https://stackoverflow.com/questions/8134960/how-to-revert-master-branch-to-upstream
If something really screwy is going on, you can try (effectively) blowing away main and resetting it to origin/main
git checkout -B main origin/main
ref: https://superuser.com/questions/273172/how-do-i-reset-master-to-origin-master/273199