Today's github tip - fixing local master
Tyler Jameson Little
beatgammit at gmail.com
Thu Jun 20 08:43:59 PDT 2013
On Tuesday, 18 June 2013 at 19:41:57 UTC, Walter Bright wrote:
> I often struggle with understanding how github works. A problem
> I was having often is that I have 3 repositories to deal with:
>
> 1. the main one on github (upstream)
> 2. my github fork of the main one (origin)
> 3. my local git repository
>
> and (2) and (3) got out of sync with (1), causing all my pull
> requests to go bonkers. What I needed was a "fix (2) and (3) so
> their masters are identical to (1)'s master." Various attempts
> at fixing it all failed in one way or another, often with
> mysterious messages, and cost me a lot of time.
>
> yebblies (Daniel Murphy) provided the solution, which is nicely
> generic:
>
> git checkout master
> git fetch upstream master
> git reset --hard FETCH_HEAD
> git push origin master -f
>
> So there it is if anyone else has this problem.
This saved me yesterday! My coworker decided to do a rebase on
master, then he made a mistake, push --force'd and in the
mean-time I accidentally git pull'd (we're a small team, I knew
he was rebasing, but still). We guard merges into master, so it's
normally not a problem.
Thanks for this! Probably saved us a quite a few WTFs!
More information about the Digitalmars-d
mailing list