Great info, Thanks. I had forgotten how to do merges where it just puts &lt;&lt;&lt;&lt; around problem code.<br><br>git pull seems to usually work fairly well , so far *knock on wood*<br><br>Max<br><br><div class="gmail_quote">
On Wed, Feb 24, 2010 at 1:40 PM, C. Titus Brown <span dir="ltr">&lt;<a href="mailto:ctb@msu.edu">ctb@msu.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br>
<br>
I think you&#39;ve all been burned by the ...ease... with which you can branch<br>
in git.  So here are some tips for working with remote branches.<br>
<br>
Terminology:<br>
<br>
  &#39;repository&#39; or &#39;repo&#39; is a standalone collection of branches; &#39;git clone&#39;<br>
  clones repos.<br>
<br>
  &#39;branch&#39; is a specific named set of code (consisting of a set of patches,<br>
  basically) within a repo.  An unlimited number of branches can co-exist<br>
  within a single repo.<br>
<br>
--<br>
<br>
Factoids:<br>
<br>
Within a repo, you switch between branches with &#39;git checkout &lt;branch&gt;&#39;.<br>
<br>
To merge between branches, you switch to one branch and do &#39;git merge &lt;other&gt;&#39;<br>
to merge in the other branch.<br>
<br>
A good way to do merges IMO is to do<br>
<br>
   git checkout &lt;branch 1&gt;<br>
   git checkout -b test_merge           # creates and checks out a copy of 1<br>
   git merge &lt;branch 2&gt;<br>
<br>
If there are merge conflicts because git can&#39;t tell how to reconcile two<br>
parallel sets of changes, it will tell you that there are conflicts and<br>
ask you to reconcile them manually.  Within the conflicted files there will<br>
be lines that start with &#39;&lt;&lt;&lt;&lt;&#39;.  We can talk more about what to do with<br>
them when you run into them, but the basic idea is you should edit out<br>
the non-functioning code and then do<br>
<br>
   git add &lt;reconciled file&gt;<br>
<br>
which will explicitly tell git that you&#39;ve reconciled the two branches.<br>
<br>
Then do a commit, and voila, test_merge will contain the merge!  (If the<br>
merge succeeds without any manual changes, you don&#39;t need to do a commit.)<br>
<br>
--<br>
<br>
Now, the problems that Khushboo are running into are caused by git&#39;s<br>
refusal to automatically push to branches that are not direct ancestors<br>
of the branch being pushed -- in other words, branches that explicitly<br>
require merges.<br>
<br>
Just to remind you,<br>
<br>
  git fetch &lt;repo&gt; &lt;remote branch&gt;:&lt;local branch&gt;<br>
<br>
takes the remote branch from repo and copies it to the local branch.<br>
Generally it will refuse to do this if the local branch already exists<br>
and is not an ancestor of the remote branch.<br>
<br>
And<br>
<br>
   git push &lt;repo&gt; &lt;local branch&gt;:&lt;remote branch&gt;<br>
<br>
is the same in reverse: you&#39;re trying to do a reverse fetch and replace<br>
the remote branch with the local branch, which git will again refuse<br>
to do if it requires a merge.<br>
<br>
Also, note,<br>
<br>
  git pull &lt;repo&gt; &lt;remote branch&gt;<br>
<br>
will attempt to merge the remote branch into whatever branch you&#39;re actually<br>
on.  It can result in merge conflicts.<br>
<br>
There are a bunch of ways to deal with these problems but you&#39;ll find that<br>
once you get more used to git it will generally &quot;just work&quot;.  For now you&#39;re<br>
stuck in the never-never land of annoyingness where it seems like nothing<br>
works without effort, but that will change...<br>
<br>
--<br>
<br>
In general, until you guys are on your feet, you should not worry too much<br>
about the push/pull/fetch details.  Just get code that works the way YOU<br>
want it to and let me worry about the nasty details.  However, you *should*<br>
(as in, I will get pissy if you don&#39;t) generally keep up with my master<br>
branch.  This involves doing<br>
<br>
   git pull <a href="http://github.com/ctb/pony-build.git" target="_blank">http://github.com/ctb/pony-build.git</a> master<br>
<br>
and resolving any conflicts that result.  This will simplify my later<br>
merges of YOUR code by keeping our branches as &quot;close cousins&quot; rather<br>
than distant cousins.<br>
<br>
Does that make sense?<br>
<br>
cheers,<br>
--titus<br>
<font color="#888888">--<br>
C. Titus Brown, <a href="mailto:ctb@msu.edu">ctb@msu.edu</a><br>
<br>
_______________________________________________<br>
pony-build mailing list<br>
<a href="mailto:pony-build@lists.idyll.org">pony-build@lists.idyll.org</a><br>
<a href="http://lists.idyll.org/listinfo/pony-build" target="_blank">http://lists.idyll.org/listinfo/pony-build</a><br>
</font></blockquote></div><br>