<?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>This is my blog &#187; git</title>
	<atom:link href="http://www.ronniealleva.org/index.php/category/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ronniealleva.org</link>
	<description>There are many like it but this one is mine</description>
	<lastBuildDate>Thu, 04 Aug 2011 22:22:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Create a Review Board review using git svn and checked in code</title>
		<link>http://www.ronniealleva.org/index.php/2010/05/10/create-a-review-board-review-using-git-svn-and-checked-in-code/</link>
		<comments>http://www.ronniealleva.org/index.php/2010/05/10/create-a-review-board-review-using-git-svn-and-checked-in-code/#comments</comments>
		<pubDate>Mon, 10 May 2010 06:45:00 +0000</pubDate>
		<dc:creator>Ronnie</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[review board]]></category>

		<guid isPermaLink="false">http://www.ronniealleva.org/?p=150</guid>
		<description><![CDATA[Our group is starting to use Review Board more and more to conduct our code reviews.  But using it with git-svn, or with anything you&#8217;ve already checked into svn can be a real hassle.  You don&#8217;t want to have uncommitted code hanging around in your computer for extended periods of time for a number of [...]]]></description>
			<content:encoded><![CDATA[<p>Our group is starting to use <a href="http://www.reviewboard.org/">Review Board</a> more and more to conduct our code reviews.  But using it with git-svn, or with anything you&#8217;ve already checked into svn can be a real hassle.  You don&#8217;t want to have uncommitted code hanging around in your computer for extended periods of time for a number of reasons, so this rendered it difficult to use for code projects that take more than a week.</p>
<p>Since I like to eat, and hence get paid so that I can afford food, I have to work on things that take longer than a week.  But luckily, git can help get a diff for review board based only on a string in the commit comments.</p>
<p>This came about when one of my <a href="http://jlorenzen.blogspot.com/">co-workers</a> posted a bash scripts someone had written that would <a href="http://mojodna.net/2009/02/24/my-work-git-workflow.html">take a git diff and make it into a svn-like diff</a>.  And that worked great.  My first attempt was to modify it to do multiple files at once, but it ended up making a diff for each revision for each file (if you need that functionality, you can get that <a href="http://gist.github.com/391247">here</a>).</p>
<p>So I pulled out python and worked on a new script, which is at the bottom of this post, or you can get it <a href="http://gist.github.com/395726">here</a>.</p>
<p>Once you download the file, you run it like this from your git repository:</p>
<pre>git-create-review.py (some grep string) &gt; diff.output</pre>
<p>The script will take the argument as a string to search for in the commit comments. This is thanks to the <em>git log &#8211;grep=foo</em> command available in git. It outputs directly to the terminal,  which you can see I&#8217;m redirecting into diff.output.  Once you have the file, you can upload to Review Board as you normally would.</p>
<p>I did it by using a search string because we use JIRA to track our work in svn.  We have pre-commit hooks to ensure that we put a JIRA number on each commit.  This helps out git as it has something to search through to get the change list.</p>
<p><strong>Known issues</strong>:</p>
<p><strong>First</strong>: It will get all the changes between the first and last revision that had the search string.</p>
<p><em>Example:</em></p>
<blockquote><address>I change File.java under JIRA-123 (now at r1). </address>
<address>Another change to File.java under JIRA-321 (now at r2). </address>
<address>I change the file again under JIRA-123 (now r3). </address>
</blockquote>
<p>This script will take all changes between 1 and 3, even if I don&#8217;t want the JIRA-321 changes to show up.</p>
<p><strong>Second</strong>: it doesn&#8217;t have any context around removed/moved files. It still should pick up a renamed file as just a completely new file, but it doesn&#8217;t have any context of renaming.  But I believe that&#8217;s the case with svn anyway.</p>
<p><strong>Third</strong>:  I am by no means a good python programmer, and might not know all the conventions that people normally follow. The code below may cause eye hemorrhaging, face hemorrhaging&#8230;pretty much any of your organs could be hemorrhaged by looking at the code. CONSIDER THIS YOUR ONLY WARNING.</p>
<p>But I did some testing with newly created files, and removed files, and binary files, but I&#8217;m sure I missed some crazy edge cases.  Let me know if you hit any snags.</p>
<p>The script follows:</p>
<p><script src="http://gist.github.com/395726.js?file=git-create-review.py"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ronniealleva.org/index.php/2010/05/10/create-a-review-board-review-using-git-svn-and-checked-in-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cloned a git-svn clone, now git svn fetch fails</title>
		<link>http://www.ronniealleva.org/index.php/2010/03/29/cloned-a-git-svn-clone-now-git-svn-fetch-fails/</link>
		<comments>http://www.ronniealleva.org/index.php/2010/03/29/cloned-a-git-svn-clone-now-git-svn-fetch-fails/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 22:53:50 +0000</pubDate>
		<dc:creator>Ronnie</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ronniealleva.org/?p=137</guid>
		<description><![CDATA[If you go to the bottom of the page for git-svn, under the &#8220;Basic Examples&#8221; section, you&#8217;ll see in there a procedure to clone a git-svn repo that someone has painstakingly already cloned from svn.  That&#8217;s great, because it will save you hours and hours of mind numbing time that would normally take someone to [...]]]></description>
			<content:encoded><![CDATA[<p>If you go to the bottom of the page for <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a>, under the &#8220;Basic Examples&#8221; section, you&#8217;ll see in there a procedure to clone a git-svn repo that someone has painstakingly already cloned from svn.  That&#8217;s great, because it will save you hours and hours of mind numbing time that would normally take someone to clone an svn repo.</p>
<p>That person may be tremendously happy&#8230;that is, until, you try to &#8220;git svn fetch&#8221; to get new revisions and branched and what have you, and you get an error message like this:</p>
<blockquote><p>Last fetched revision of (some branch or tag) was r3421, but we are about to fetch: r3421!</p></blockquote>
<p>In an attempt to fix it, you may find <a href="http://www.jukie.net/bart/blog/20080916155113">this blog post</a>, saying to remove the .ref files from your svn directory, which also proves fruitless.</p>
<p>The fix: modify the .git/svn/.metadata file so that the branches-maxRev and tags-maxRev equals the latest commit revision in svn.  So it should look like this after you are done:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">; This file is used internally by git-svn
; You should not have to edit it
[svn-remote &quot;svn&quot;]
 reposRoot = (svn server name)
 uuid = c08781d2-f03e-0410-8c7c-e884ea3e41f3
 branches-maxRev = 17224
 tags-maxRev = 17224</pre></div></div>

<p>Where 17224 was our latest revision.</p>
<p>I got the idea from git-svn&#8217;s webpage, where it states:</p>
<blockquote><p>If the subset of branches or tags is changed after fetching, then .git/svn/.metadata must be manually edited to remove (or reset) branches-maxRev and/or tags-maxRev as appropriate.</p></blockquote>
<address> </address>
<p>I must caveat this with the fact that I have no idea why this works. Git svn is still black magic to me, and making this work is akin to me throwing muskrat bones onto a flaming pyre, and drawing conclusions from the charred remains.  Maybe someone with more git knowledge could drop it off here?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ronniealleva.org/index.php/2010/03/29/cloned-a-git-svn-clone-now-git-svn-fetch-fails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More git-svn fun: working with svn branches</title>
		<link>http://www.ronniealleva.org/index.php/2009/09/16/more-git-svn-fun-working-with-svn-branches/</link>
		<comments>http://www.ronniealleva.org/index.php/2009/09/16/more-git-svn-fun-working-with-svn-branches/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 05:47:05 +0000</pubDate>
		<dc:creator>Ronnie</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.ronniealleva.org/?p=50</guid>
		<description><![CDATA[So, last time I detailed using git to work with your svn trunk. But many of you asked, &#8220;But Ralph, my svn repo has many branches and many tags because developers love branches and tags! How can I work with that?&#8221; Well, since no one reads this blog and no one actually asked me that, [...]]]></description>
			<content:encoded><![CDATA[<p>So, <a href="http://www.ronniealleva.org/index.php/2008/08/28/using-git-and-subversion-in-5-easy-steps/">last time</a> I detailed using git to work with your svn trunk.  But many of you asked, &#8220;But Ralph, my svn repo has many branches and many tags because developers love branches and tags!  How can I work with that?&#8221;  Well, since no one reads this blog and no one actually asked me that, also misspelling my name in the process, let&#8217;s just pretend that what I write is relevant.</p>
<p>So you want to work with multiple svn branches (not to be confused with git branches).  What you have to do is clone the svn repository in a different way, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ git svn clone https://somesvnrepo/svn/project -T trunk -b branches -t tags</pre></div></div>

<p>This should work in most cases.  The arguments to the -T, -b, and -t switches are the paths that the trunk, branches, and tags are in respectively. Typically, your branches and tags should be what I put above, but just in case it is different in your case, there you go.</p>
<h2>Working with your shiny repo</h2>
<p>After a short time in which humans achieve interstellar travel, git finishes cloning, and you have access to the entire svn repository.  Now, let&#8217;s say you wanted to start working on trunk.  Like before, you should checkout a branch, but this time it&#8217;s going to use trunk as it&#8217;s parent:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ git checkout -b BranchOfTrunk trunk</pre></div></div>

<p>But Lo!  You have the entire repo, so you can checkout that branch from whatever branch you have in subversion.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ git checkout -b BranchOfSubversionBranch subversion-branch</pre></div></div>

<p>Now, you can switch between BranchOfTrunk and BranchOfSubversionBranch, and you&#8217;ll get all the code associated with trunk and subversion-branch respectively.  No more checkout of a branch ever again, wasting precious keystrokes you could use to post to Facebook.  </p>
<p>If a new svn branch is created on the server, make sure to run the following command to see it:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ git svn fetch
. (updating blah blah)
.
.
$ git branch -a</pre></div></div>

<p>The last command will show you all the branches, local (your own branches) and remote (every dumb svn branch), for this repository.</p>
<p>NOTE: <strong>git svn fetch</strong> and <strong>git svn rebase</strong> are almost exactly the same.  <strong>fetch</strong> will update the entire git repository with anything not received from svn.  <strong>rebase</strong> is concerned only with the parent of the branch you have checked out.  If you recall last time, <strong>git svn rebase</strong> was equivalent to <strong>svn update</strong>.  Now you can work with the same workflow as I mentioned before, working, committing locally, rebasing, etc.  </p>
<h2>Merging from subversion branch to trunk?  BALDERDASH!</h2>
<p>Now, let&#8217;s say that you want to commit a series of changes into a subversion branch, but you also want to commit the same changes in trunk also.  What I&#8217;m going to show you is the workflow that I go through most of the time.  I think it&#8217;s the most effective way to accomplish it in git.  </p>
<p>First, you can run a fake dcommit.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ git svn dcommit --dry-run
Committing to https://svnserver/svn/project/branches/subversion-branch ...
diff-tree b64fdc9250bbe04b3246214ade509e0b0d9d912d~1 b64fdc9250bbe04b3246214ade509e0b0d9d912d</pre></div></div>

<p>The <strong>&#8220;&#8211;dry-run&#8221;</strong> is key here, for two reasons.  First, you&#8217;ll be able to see what branch you are actually committing to in subversion. Not a bad idea, since you&#8217;re working in a git repo that has all your subversion branches.</p>
<p>Second, you&#8217;ll see a diff tree with some of the commit hashes, one corresponding to each time you did a commit locally, in order.  You will want to keep the values of the hash around, because next we are going to <strong>&#8220;cherry-pick&#8221;</strong> them into trunk:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">$ git checkout BranchOfTrunk
Switched to branch &quot;BranchOfTrunk&quot;
$ git cherry-pick b64fdc9
Finished one cherry-pick.
Created commit e4a7971:  Your commit comments here
 12 files changed, 58 insertions(+), 66 deletions(-)</pre></div></div>

<p>You&#8217;ll notice I only used the first 7 digits of the hash (b64fdc9) to do the cherry-pick.  That&#8217;s all you need to use&#8230;git will pick out the revision from just those seven characters.  What this does is pulls the change from the other branch into this branch.  If you have more than one commit, you should do this multiple times, in the order of the commits.  But then you have the things you did on the branch ready to be checked into trunk!  </p>
<p>This is the way I usually work.  You may decide that doing a subversion merge is easier for what you are trying to do (I sometimes do also).  I&#8217;d also like to know if there is an easier way to do this.  This doesn&#8217;t seem the easiest way, but was the easiest way I could find so far.  And I googled for like&#8230;20 minutes.</p>
<p>Hopefully this helps&#8230;someone.  One person, at least.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ronniealleva.org/index.php/2009/09/16/more-git-svn-fun-working-with-svn-branches/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Git and Subversion in 5 Easy Steps</title>
		<link>http://www.ronniealleva.org/index.php/2008/08/28/using-git-and-subversion-in-5-easy-steps/</link>
		<comments>http://www.ronniealleva.org/index.php/2008/08/28/using-git-and-subversion-in-5-easy-steps/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 04:44:23 +0000</pubDate>
		<dc:creator>Ronnie</dc:creator>
				<category><![CDATA[git]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.ronniealleva.org/index.php/2008/08/28/using-git-and-subversion-in-5-easy-steps/</guid>
		<description><![CDATA[I recently wanted to use a distributed version control system to learn and to try it out, since I have been hearing great things about it.  The only issue is that my team (and like 1 million other teams universe wide) currently uses Subversion, and trying to get them to switch over would be like [...]]]></description>
			<content:encoded><![CDATA[<p>I recently wanted to use a distributed version control system to learn and to try it out, since I have been hearing great things about it.  The only issue is that my team (and like 1 million other teams universe wide) currently uses Subversion, and trying to get them to switch over would be like trying to punch a redwood down.</p>
<p>But! Not all is lost.  You can use git with Subversion.  This can give you some of the benefits of using a DVCS without having to change everything you do.  I believe you can do this also with Mercurial&#8230;I went with git because I had read somewhere it had the best support to working with Subversion. AND RANDOM INTERNET BLOGS ARE ALWAYS RIGHT.</p>
<p>First of all, I will say that I used <a href="http://utsl.gen.nz/talks/git-svn/intro.html">this</a> as a guide when I was working.  It&#8217;s a great start to doing this stuff.  I&#8217;ll also assume you can find and install git on your own, since you&#8217;re all-grow&#8217;d up now.</p>
<h2>Step 1: Creating a local repo</h2>
<p>Ok so let&#8217;s get started.  The first step is to get the subversion library.  That webpage I gave you gives you four different ways of doing it, but I decided to go with the fourth option, which is cloning the entire Subversion repository.  You can do that by doing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> clone https:<span style="color: #000000; font-weight: bold;">//</span>svnserver<span style="color: #000000; font-weight: bold;">/</span>project<span style="color: #000000; font-weight: bold;">/</span>trunk</pre></div></div>

<p>Now, you should know that this could take a while.  You might as well go and eat dinner for the next three days while this completes.  Just kidding, this took me about an hour or so while I was working remotely over a VPN, so it&#8217;s not so bad.  Our project has about 8000 revisions, and about 230 MBs of files.</p>
<p>So you&#8217;re probably wondering &#8220;But now if I have the whole history, isn&#8217;t it going to take like&#8230;a bazillion bytes on my disk?&#8221;  To that I say &#8220;Non&#8221;&#8230;it uses compression, and my git repo ended up being about 1 MB bigger than my subversion one.</p>
<h2>Step 2: Create a branch</h2>
<p>From there, you can start working in git!  The first thing you&#8217;ll probably want to do is create a branch:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> branch someNeatoBranch</pre></div></div>

<p>To change to that branch:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> checkout someNeatoBranch</pre></div></div>

<p>Now you are working on this particular branch.  Note you can do this in one step by doing:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> checkout <span style="color: #660033;">-b</span> someNeatoBranch</pre></div></div>

<p>which will create it and put you on it to work.</p>
<h2>Step 3: Commit locally</h2>
<p>Now you can edit the files to your heart&#8217;s content.  And commit locally as often as you like, by doing</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-a</span></pre></div></div>

<p>You can commit individual files by specifying them, but -a just grabs them all.</p>
<h2>Step 4: Commit back to Subversion</h2>
<p>Once you&#8217;re ready to commit back into the main Subversion repo, first you need to pull all the changes from there, to make sure there are no conflicts. You can do this by using this command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> rebase</pre></div></div>

<p>This will pull down the latest code and apply your code on top of it, merging if necessary.  Then to commit back to Subversion, you use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> dcommit</pre></div></div>

<p>And you will notice that your files are committed back to the repo without any more intervention from you!  But where are your comments?  Well, all the comments from the commits you did locally will be used to commit to Subversion.  It will also do that many commits.  So if you did 5 different commits locally, it will turn into 5 different Subversion commits.  As long as your team members don&#8217;t worry about the revision number spirialing up towards the heavens, it should be ok.</p>
<h2>Step 5: Brunch!</h2>
<p>This is a pretty simple workflow to get you started on using git with Subversion, but it&#8217;s not even half the story.  There&#8217;s so much more powerful stuff with the branching aspect, and I even haven&#8217;t tried it yet to share work with my coworkers before commiting to svn (I&#8217;m kinda like a git island at the moment).  But try it out, and then check out some of the resources below that helped me get started.</p>
<p>Also, you might want to check how my co-worker <a href="http://jlorenzen.blogspot.com/2008/08/me-lovin-git.html">James </a>one-upped me.  He was working on some highly experimental code that he wanted to share with a teammate, and created a true git repo in approximately 8 seconds, from existing code.</p>
<p><strong><br />
</strong></p>
<h2><strong>Resources</strong></h2>
<ul>
<li><a href="http://utsl.gen.nz/talks/git-svn/intro.html">An introduction to git-svn for Subversion/SVK users and deserters</a></li>
<li><a href="http://git.or.cz/course/svn.html">Git &#8211; SVN Crash Course</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ronniealleva.org/index.php/2008/08/28/using-git-and-subversion-in-5-easy-steps/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

