Today's github tip - fixing local master

Martin Nowak code at dawg.eu
Sun Jun 23 12:13:18 PDT 2013


On 06/18/2013 09:41 PM, 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:
 >

IMHO it's much easier to understand git from bottom up.
Git is based on a very simple object model.
It only knows 4 types Blob, Tree, Commit and Tag.
http://git-scm.com/book/en/Git-Internals-Git-Objects
With that you can think of any constellation in terms of commit diagrams 
like these http://git-scm.com/book/ch3-6.html.

And the last bit is to understand what git commands actually do.
This is the problematic part of git. Some commands do basic operations 
others do more complicated stuff. The later usually have gotchas one 
needs to be aware of. I personally found that using explicit and more 
verbose commands was helpful to learn git faster.

 >     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.
 >

I never use my remote master branch (origin).
What do you need it for?

 > 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.

I also tend to prefer the explicit fetch and rebase or reset over pull 
because what git pull does depends on your .gitconfig.


More information about the Digitalmars-d mailing list