Today's github tip - fixing local master

David d at dav1d.de
Tue Jun 18 13:47:49 PDT 2013


Am 18.06.2013 21:41, schrieb Walter Bright:
> 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 should not be generalized!
this resets everything you have done on master to upstream! Anything is
gone, if you actually end up resetting the wrong branch, take a look
into "git reflog", which allows you to revert the hard-reset


More information about the Digitalmars-d mailing list