<?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; remote</title>
	<atom:link href="http://techblog.floorplanner.com/tag/remote/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>Working with git branches</title>
		<link>http://techblog.floorplanner.com/2008/12/14/working-with-git-branches/</link>
		<comments>http://techblog.floorplanner.com/2008/12/14/working-with-git-branches/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 17:33:16 +0000</pubDate>
		<dc:creator>Willem van Bergen</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[bash colors]]></category>
		<category><![CDATA[branches]]></category>
		<category><![CDATA[checkout]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[origin]]></category>
		<category><![CDATA[pull]]></category>
		<category><![CDATA[push]]></category>
		<category><![CDATA[remote]]></category>

		<guid isPermaLink="false">http://techblog.floorplanner.com/?p=321</guid>
		<description><![CDATA[Because Jaap finally convinced Gert-Jan, we have moved to the Git version control system for the main Floorplanner repository. Now we can use branches for different functionality far more easily. As an easy reminder to some common Git tasks I will need regularly, I have written down some Git recipes. This is basically meant for [...]]]></description>
			<content:encoded><![CDATA[<p>Because <a href="http://techblog.floorplanner.com/2008/12/09/git-vs-svn-for-bosses">Jaap finally convinced Gert-Jan</a>, we have moved to the Git version control system for the main Floorplanner repository. Now we can use branches for different functionality far more easily. As an easy reminder to some common Git tasks I will need regularly, I have written down some Git recipes. This is basically meant for me and my fellow developers, but maybe it can help you as well. Suggestions to improve my workflow are welcome!</p>
<h3>Displaying the current branch in your prompt</h3>
<p>Because I will be using branches more regularly now, it is nice to know what branch I am currently working in. <code>git branch</code> will provide this information, but it can be more direct by including the current branch in your terminal prompt. </p>
<p>To display the current git branch in my terminal prompt, I have added <a href="http://gist.github.com/5017"> the following</a> to my Bash configuration file <code>~/.profile</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family: Monaco,monospace;">parse_git_branch() {
  git branch 2&gt; /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
}
&nbsp;
PS1='\[\033[01;37m\]\w\[\033[00;35m\]$(parse_git_branch)\[\033[00m\] \$ '</pre></div></div>

<p>I use a black, semi-transparent terminal with white text, and pink branch names. <a href="http://www.systhread.net/texts/200703bashish.php">Change the colors</a> to your own liking!</p>
<p><img src="http://techblog.floorplanner.com/wp-content/uploads/2008/12/picture-4.png" alt="Git - branch in terminal" title="Git - branch in terminal" width="574" height="395" class="alignnone size-full wp-image-349" /></p>
<h3>Working on a remote branch that is not available locally yet</h3>
<p>If you want to help out on a branch that somebody else started and has pushed it to the remote repository, you can checkout this branch and make it &#8220;track&#8221; the remote branch.</p>

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

<p>In this example, <strong>origin/newbranch</strong> is the branch in the remote repository. Locally, this branch will be called <strong >newbranch</strong >. A simple <code>git pull</code> will update my branch with the latest changes from the remote branch later on, <code>git push</code> will send my changes to the remote server. </p>
<p><img src="http://techblog.floorplanner.com/wp-content/uploads/2008/12/picture-1.png" alt="Git - track remote branch" title="Git - track remote branch" width="574" height="395" class="alignnone size-full wp-image-336" /></p>
<h3>Creating a new branch and pushing it to the remote server</h3>
<p>Sometimes I want to start a new branch myself if I want to work on a new feature or on disruptive refactoring of the main codebase.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family: Monaco,monospace;">$ git checkout -b feature</pre></div></div>

<p>The <em>feature</em> branch is now available locally. After some time, I want to share my current changes in this branch with other developers. I should make the branch available in the remote repository so other can access it like I described above.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family: Monaco,monospace;">$ git commit -m &quot;Added initial version of %feature%&quot;
$ git push origin feature</pre></div></div>

<p><img src="http://techblog.floorplanner.com/wp-content/uploads/2008/12/picture-2.png" alt="Git - push local branch to remote" title="Git - push local branch to remote" width="574" height="395" class="alignnone size-full wp-image-341" /></p>
<p>The feature branch will now be available to other developers as well. Note that the local <em>feature</em>-branch is <strong>not</strong> tracking the remote branch of the same name. This can be enabled by <a href="http://graysky.org/2008/12/git-branch-auto-tracking/">changing the configuration</a> of the repository.</p>
<h3>Merging a branch</h3>
<p>After work is completed on my <em>feature</em>-branch and it is tested thoroughly, I want to merge the branch with the master branch of the project. To make sure the merge with the master branch is seamless and all possible merge conflicts are handled beforehand, we first run <code>git rebase</code>. This ensures that the changes in the <em>feature</em> branch are relative to the latest commit to the master branch and can therefore be applied by a &#8220;fast forward&#8221;. It is best to run <code>git rebase</code> from time time to time while you are developing in the <em>feature</em> branch to make sure your work does not divert to much from the main development in the master branch.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family: Monaco,monospace;">  # make sure that the current branch is seamlessly
  # mergeable with the master branch
$ git rebase master
  # switch to the master branch
$ git checkout master
  # now, merge the feature branch
$ git merge feature
  # publish the merge to the remote server
$ git push origin master</pre></div></div>

<p><img src="http://techblog.floorplanner.com/wp-content/uploads/2008/12/picture-3.png" alt="Git - merge branch" title="Git - merge branch" width="574" height="395" class="alignnone size-full wp-image-343" /></p>
<p>I can now delete the local and remote feature branch, as the changes have been incorporated in the master branch:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family: Monaco,monospace;">$ git branch -d feature
$ git branch -d -r origin/feature</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://techblog.floorplanner.com/2008/12/14/working-with-git-branches/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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>
