<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Floorplanner Tech Blog &#187; merging</title>
	<atom:link href="http://techblog.floorplanner.com/tag/merging/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.floorplanner.com</link>
	<description>Our latest geek adventures!</description>
	<lastBuildDate>Tue, 16 Mar 2010 18:45:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Remote branches in git</title>
		<link>http://techblog.floorplanner.com/2008/09/13/remote-branches-in-git/</link>
		<comments>http://techblog.floorplanner.com/2008/09/13/remote-branches-in-git/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 13:26:11 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Collaboration]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[branches]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[merging]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=165</guid>
		<description><![CDATA[I have been using git for a while now, and I believe I have the the basic workflow under control.  Committing, reverting, using local branches for major refactoring work: been there, done that!   However, I recently got some collaborators on my github-projects, I had to start working with other remote repositories and [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using git for a while now, and I believe I have the the basic workflow under control.  Committing, reverting, using local branches for major refactoring work: been there, done that! <img src='http://techblog.floorplanner.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  However, I recently got some collaborators on <a href="http://github.com/wvanbergen/">my github-projects</a>, I had to start working with other remote repositories and branches. </p>
<p>I found <a href="http://blog.ericgoodwin.com/2008/4/6/pushing-and-pulling-branches-on-github">this blog post</a>, which was really helpful. I am sharing some others things that helped me in the last couple of weeks. Hopefully, this saves other people some time Googling. If you know a better ways to accomplish these tasks, please let me know!</p>
<h3> Things to remember about remote branches </h3>
<p>Because I had some troubles discovering how to properly work with remote repositories, I am sharing what I found. The most important things to remember:</p>
<ul>
<li>Never forget to switch to the correct local branch (using <code>git checkout <em>local-branch</em></code>). This is easier if you <a href="http://techblog.floorplanner.com/2008/12/14/working-with-git-branches/">setup your command prompt to include your current branch</a>.</li>
<li> The names of the local and remote do not need to match, but it is highly recommended if you do not want to go crazy <img src='http://techblog.floorplanner.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</li>
<li> Before you can push changes from a local branch to a remote branch, all the commits of the remote branch have to be included in your local branch. This can be done using by executing <code>git pull <em>remote-name</em> <em>remote-branch</em></code> in your local branch.
</ul>
<h3> Checking out a newly created branch in a remote repository </h3>
<p><a href="https://github.com/barttenbrinke">Bart</a> is implementing Merb log parsing for <a href="https://github.com/wvanbergen/request-log-analyzer">request-log-analyzer</a>. He has put his progress in a separate branch of the github project. My local repository does not yet include this branch, but I want to check it out. Note that I am using a different name than the branch name on the github project.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family: Monaco,monospace;">$ git branch merb origin/generic_base
$ git checkout merb</pre></div></div>

<p><strong>Update:</strong> The same can be accomplished with a single command, which sets up <a href="http://www.gitready.com/beginner/2009/03/09/remote-tracking-branches.html">remote tracking</a> as well:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family: Monaco,monospace;">$ git checkout -b merb origin/generic_base</pre></div></div>

<p>When the new functionality is finished, the following commands will merge the changes in the merb branch to the master branch.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family: Monaco,monospace;">  # goto my local master branch and merge the merb-branch
$ git checkout master
$ git merge merb
&nbsp;
  # push the changes to the master branch on github
$ git push origin master</pre></div></div>

<h3> Merging back a fork </h3>
<p><a href="http://github.com/gbdev">Wes Hays</a> is helping me out on the <a href="http://github.com/wvanbergen/scoped_search">scoped_search plugin</a>. He implemented <code>OR</code> in the query language in his <a href="http://github.com/gbdev/scoped_search/tree/master">own fork</a>. I wanted to merge his changes back to master branch:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family: Monaco,monospace;">  # add a reference to the remote repository 
  # and fetch the latest data from that repository
$ git remote add gbdev git://github.com/gbdev/scoped_search.git
$ git fetch gbdev
&nbsp;
  # create a local branch for the fork to follow a remote branch
$ git branch gbdev-fork gbdev/master
$ git checkout gbdev-fork</pre></div></div>

<p>Now, my local <strong>gbdev-fork</strong> branch contains Wes&#8217;s code. Because Wes&#8217;s repository was forked from my repository, git will know that most of the history of my <code>master</code> branch and <code>gbdev-fork</code> branch is the same. </p>
<p>After some testing, I was ready to include his changes by merging the <code>gbdev-fork</code> branch into my local master branch:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family: Monaco,monospace;">  # go back to my master branch, and merge the changes
$ git checkout master
$ git merge gbdev-fork
  # push the changes to the master branch at hithub
$ git push origin master</pre></div></div>

<p><strong>Update:</strong> I found out that you do not have to create a local branch when merging a remote branch. You can do read-only work directly on the remote branch:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family: Monaco,monospace;">  # Add a new remote to your repository and fetch updates
$ git remote add gbdev git://github.com/gbdev/scoped_search.git
$ git fetch gbdev
&nbsp;
  # Checkout the remote branch for testing (read-only)
$ git checkout gbdev/master
&nbsp;
  # After successful testing, merge the branch into the master branch:
$ git checkout master
$ git merge gbdev/master
$ git push origin master</pre></div></div>

<h3> Pushing tags to a remote repository </h3>
<p>You can create tags locally, but you probably want to send them to the remot repository as well:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family: Monaco,monospace;">  # create a local tag &quot;tagname&quot; with the given message.
$ git tag -a &quot;tagname&quot; -m &quot;message&quot; 
  # send your tags to the remote repository &quot;origin&quot;
$ git push origin --tags</pre></div></div>

<h3> Deleting tags </h3>
<p>Sometimes, you want to remove a faulty tag. If you already pushed your tags to a remote repository, you probably want to delete it from that repository, too,</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family: Monaco,monospace;">  # remove local tag
$ git tag -d tagname
  # remove tag from remote using colon syntax
$ git push :tagname</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2008/09/13/remote-branches-in-git/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
