<?xml version="1.0" encoding="UTF-8"?>
<guide>
  <body>&lt;p&gt;Suppose you fork &lt;a href=&quot;http://github.com/wycats/merb-core/tree/master&quot;&gt;http://github.com/wycats/merb-core/tree/master&lt;/a&gt; by clicking on the &amp;#8220;fork&amp;#8221; button at the top of that page.&lt;br /&gt;
&lt;img src=&quot;http://img.skitch.com/20080303-q2aceaadcqk59kqck4b199bdmh.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;(Image from the &lt;a href=&quot;http://railsontherun.com/2008/3/3/how-to-use-github-and-submit-a-patch&quot;&gt;Rails on the Run tutorial&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;That copies the repository to your github account, with username &lt;code&gt;username&lt;/code&gt; (for example). Once you&amp;#8217;ve &lt;a href=&quot;http://github.com/guides/providing-your-ssh-key&quot;&gt;provided your &lt;span class=&quot;caps&quot;&gt;SSH&lt;/span&gt; key&lt;/a&gt;, you can &lt;a href=&quot;http://github.com/guides/getting-a-copy-of-your-github-repo&quot;&gt;check out this remote branch to a directory on your local computer&lt;/a&gt; with git&amp;#8217;s clone command:&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;&lt;br /&gt;
git clone git@github.com:username/merb-core.git&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The above command copies the repository to the directory in which it is run with the following remote reference in your &lt;code&gt;.git/config&lt;/code&gt; file&lt;sup class=&quot;footnote&quot;&gt;&lt;a href=&quot;#fn1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
[remote &quot;origin&quot;]
	url = git@github.com:username/merb-core.git
	fetch = +refs/heads/*:refs/remotes/origin/*
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To also be able to pull in updates from &lt;code&gt;wycats/merb-core&lt;/code&gt;, add it to your remote references:&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;&lt;br /&gt;
git remote add wycats git://github.com/wycats/merb-core.git&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The above command adds the following remote reference to your &lt;code&gt;.git/config&lt;/code&gt; file&lt;sup class=&quot;footnote&quot;&gt;&lt;a href=&quot;#fn1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
[remote &quot;wycats&quot;]
	url = git://github.com/wycats/merb-core.git
	fetch = +refs/heads/*:refs/remotes/wycats/*
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;h2&gt;Manually Pull from Each Repository&lt;/h2&gt;
&lt;p&gt;Once the remote branch is created (You only have to do this once.), you can pull in new changes:&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;&lt;br /&gt;
git checkout master&lt;br /&gt;
git pull wycats master&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you don&amp;#8217;t wish for an automatic merge to happen, you can instead fetch and merge:&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;&lt;br /&gt;
git checkout master&lt;br /&gt;
git fetch wycats&lt;br /&gt;
git merge wycats/master&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;h2&gt;Shortcut: Pull from Both Repositories in One Command&lt;/h2&gt;
&lt;p&gt;NB: I&amp;#8217;m not sure why, but for this shortcut to work for me, I had to first pull manually once (as instructed above).&lt;/p&gt;
&lt;p&gt;To make things easier, you can create an alias that fetches from &lt;code&gt;origin&lt;/code&gt; and &lt;code&gt;wycats&lt;/code&gt; and octopus merges them with the current branch on your local machine. Paste the following in your &lt;code&gt;.git/config&lt;/code&gt; file&lt;sup class=&quot;footnote&quot;&gt;&lt;a href=&quot;#fn1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;pre&gt;
[alias]
	pu = !&quot;git fetch origin -v; git fetch wycats -v; git merge wycats/master&quot;
&lt;/pre&gt;
&lt;p&gt;You can delete both &lt;code&gt;-v&lt;/code&gt;&amp;#8216;s, which stand for verbose, if you don&amp;#8217;t care for git to explain what&amp;#8217;s happening in detail. Now, all you have to type to stay completely up to date is:&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;&lt;br /&gt;
git pu&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;
&lt;p class=&quot;footnote&quot; id=&quot;fn1&quot;&gt;&lt;sup&gt;1&lt;/sup&gt; To get a better understanding of git configuration files, go to the &lt;a href=&quot;http://www.kernel.org/pub/software/scm/git/docs/git-config.html&quot;&gt;git-config(1) Manual Page&lt;/a&gt;, search for &amp;#8220;syntax&amp;#8221;, and read the first few paragraphs of the &amp;#8220;Configuration File&amp;#8221; section. Then, skim the &amp;#8220;Variables&amp;#8221; section to get a sense of what variables you can configure.&lt;/p&gt;
</body>
  <created-at type="datetime">2008-06-06T13:39:30-07:00</created-at>
  <id type="integer">48</id>
  <permalink>keeping-a-git-fork-in-sync-with-the-forked-repo</permalink>
  <title>Keeping a git fork in sync with the forked repo</title>
  <updated-at type="datetime">2009-08-16T09:57:14-07:00</updated-at>
  <user-id type="integer">106587</user-id>
</guide>
