Today's github tip - fixing local master

Daniel Murphy yebblies at nospamgmail.com
Tue Jun 18 17:55:13 PDT 2013


"Walter Bright" <newshound2 at digitalmars.com> wrote in message 
news:kpqd65$qs7$1 at digitalmars.com...
>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.

As others have noted, this will completely discard any commits in master, 
and should be used with caution.  It is comparable to removing a virus by 
manually replacing system files.

It is probably possible to prevent git from accepting commits to master, but 
I have never been able to get it to work.  Maybe something like this: 
https://gist.github.com/Simbul/1781656




More information about the Digitalmars-d mailing list