<?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>Luanatic with features &#187; git</title>
	<atom:link href="http://www.pplux.com/category/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pplux.com</link>
	<description>PpluX &#039;s blog</description>
	<lastBuildDate>Mon, 11 May 2009 08:21:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>from subversion to git</title>
		<link>http://www.pplux.com/2008/11/26/from-subversion-to-git/</link>
		<comments>http://www.pplux.com/2008/11/26/from-subversion-to-git/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 14:55:55 +0000</pubDate>
		<dc:creator>PpluX</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[recetas]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[SCM]]></category>

		<guid isPermaLink="false">http://www.pplux.com/?p=194</guid>
		<description><![CDATA[Recently I&#8217;ve been playing with git and I found it fascinating!, for those that still don&#8217;t know what it is, git is a really fast distributed revision control system (wikipedia). Now the problem is how to switch from subversion to git, fortunately git-svn helps a lot and we can play with git and subversion in [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been playing with git and I found it fascinating!, for those that still don&#8217;t know what it is, git is a really fast distributed revision control system (<a href="http://en.wikipedia.org/wiki/Git_%28software%29">wikipedia</a>). Now the problem is how to switch from subversion to git, fortunately <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a> helps a lot and we can play with git and subversion in many ways. Let&#8217;s talk about them from the easiest to the not-so-easy way. I&#8217;m supposing here that you want to move from a centralized subversion to a git repository that probably will be online on a server.</p>
<h2>Complete migration from subversion to git</h2>
<p>This is for those that want to throw  subversion away completely, for some reason this is the easiest way to switch. First what you would do on the server:</p>
<p><code><span class="blue"># first clone the repository from subversion<br />
#  if you can use file:// it will be faster,<br />
#  otherwise use </span><span class="red">http://your-project-url.com/svn/MySuperProject </span><br />
[server]$ git svn clone -s <span class="red">file:///home/pplux/.../svn/MySuperProject</span> tmp<br />
<span class="blue"># clone to a bare new git repository (with no track of subversion)</span><br />
[server]$ git clone --bare file://`pwd`/tmp MySuperProject<br />
<span class="blue"># remove the old git repo from subversion, no longer needed</span><br />
[server]$ rm -rf tmp/<br />
<span class="blue"># update server info, for "dumb" servers this is needed</span><br />
[server]$ cd MySuperProject/<br />
[server]$ git --bare update-server-info<br />
</code></p>
<p>Now clients can simple clone your repository and start working:<br />
<code><span class="blue"># use this for normal-read-only, or maybe you could use ssh://<br />
#   if you plan to upload data.</span><br />
[client] $ git clone <span class="green">http://your-server-url.com/git/MySuperProject</span><br />
</code></p>
<h2>Mirroring the subversion repository and keep subversion</h2>
<p>Here we want to keep the subversion repository like the main reference of the project, but let people (or ourselves) use git for development. The reason to mirror the subversion is just a matter of speed, it is much faster to clone an existing git repository than cloning from subversion each time. </p>
<p>Here we will need to do a bit more of work, but it&#8217;s a much smoother way to migrate from subversion to git. First what we need to do on the server:</p>
<p><code><span class="blue"># Create and initialize a bare git repository</span><br />
[server]$ mkdir MySuperProject[server]$ cd MySuperProject/<br />
[server]$ git --bare init<br />
Initialized empty Git repository in /home/pplux/.../MySuperProject/<br />
<br/><br />
<span class="blue"># set svn project to import</span><br />
[server]$ git --bare svn init -s <span class="red">http://your-server-url.com/svn/MySuperProject</span><br />
<br/><br />
<span class="blue"># fetch svn data (sloooow)</span><br />
[server]$ git --bare svn fetch --all<br />
    A   src/CMakeLists.txt<br />
        A   CMakeLists.txt<br />
        W: +empty_dir: trunk/include<br />
...<br />
<br/><br />
<span class="blue"># auxiliary files to help "dumb" servers</span><br />
[server]$ git --bare update-server-info<br />
</code></p>
<p>Now the client, here we will do much more work than before to setup both the origin from the git mirror and the subversion config to commit there future changes.</p>
<p><code><span class="blue"># Create and initialize our copy of the git repository</span><br />
[client] $ mkdir MySuperProject<br />
[client] $ cd MySuperProject/<br />
[client] $ git init<br />
Initialized empty Git repository in /Users/pplux/projects/MySuperProject/.git/<br />
<br/><br />
<span class="blue"># setup the server as the initial origin of data</span><br />
[client] $ git remote add origin <span class="green">http://your-server-url.com/git/MySuperProject</span><br />
<br/><br />
<span class="blue"># also tell git to fecth data from the remote origin(that case svn)</span><br />
[client] $ git config --add remote.origin.fetch '+refs/remotes/*:refs/remotes/*'<br />
<br/><br />
<span class="blue"># fetch data from the git mirror(takes a bit)</span><br />
[client] $ git fetch<br />
got 2c68737541f19685f667f601a502447425d1fcfe<br />
walk 2c68737541f19685f667f601a502447425d1fcfe<br />
got d4916373650b9bb636c0284dd501e6c7bfa8e304<br />
got 13af9568120f8e7771bd386d9b7dadf69f1181cb<br />
...<br />
<br/><br />
<span class="blue"># setup the original subversion as</span><br />
[client] $ git svn -s init <span class="red">http://your-server-url.com/svn/MySuperProject</span><br />
<br/><br />
<span class="blue"># rebuild data...</span><br />
[client] $ git svn fetch<br />
Rebuilding .git/svn/trunk/.rev_map.1a3bf6a2-ba3d-0410-9263-a3f888f14dcd ...<br />
r1 = 126490373bfbc2a770d762398b67fffeef73bead<br />
r2 = a2288725c8c68ef426b97cf2b28a9135a34734d3<br />
r3 = 4158b92a5c68489bb6ff2b4f4567cf8f830d7282<br />
<br/><br />
<span class="blue"># to start working create a master that will track "trunk"</span><br />
[client] $ git checkout -b master -t trunk<br />
</code></p>
<h2> Reasons for switching to git </h2>
<p>The post ends here you can safely stop reading now, but if you ask me, there are some good reasons to switch to git:</p>
<ul>
<li> it&#8217;s faster, not only faster when doing actual SCM work, it allows you to develop faster, no need to wait while the commit is transmitted to the server, you can work offline wherever you are&#8230; </li>
<li> it works well with subversion, you can use it even if the main project never moves from a subversion repository or you are the only one using git while everybody else is using subversion </li>
<li> you don&#8217;t need to develop a full feature before a commit, you can work on your own doing commits often without worrying about anybody else.</li>
<li> git is meant to work on branches, this is a different approach from the normal subversion use, with git you are supposed to work on branches, and it&#8217;s great! I like to develop different &#8220;features&#8221; on different branches, I can switch the branch, do several things at the same time&#8230; and so on.</li>
<li>you have the whole history, not just the last commit.</li>
<li>it&#8217;s secure, you don&#8217;t need several people to share the same repository, git &#8220;default&#8221; model works in a different way where each person has its own public git. But, everything in git is hashed, even branches, so you can easily check if your private git has the same things as the remote git (that&#8217;s difficult to achieve with subversion)</li>
<li> it&#8217;s like vim vs notepad! I like git because is fun, it can do many many things, and it&#8217;s always good to have something new to play with.</li>
<li> if CVS was for dinosaurs when you started using SVN, now SVN is for the Neanderthals&#8230; so start using git!</li>
<li> You don&#8217;t have to be a ruby developer to use git! git is another SCM&#8230; not the cool tool just for cool ruby developers&#8230; come on.</li>
<li> Because Linus Torvalds made it:<br/><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/4XpnKHJAok8&#038;hl=es&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/4XpnKHJAok8&#038;hl=es&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></li>
<li> &#8230; well, maybe Linus is not a good reason to use it&#8230; I don&#8217;t fancy calling people ugly and idiot, anyway git is great.</li>
</ul>
<p>And big thanks to <a href="http://slack.codemaniacs.com/">slack</a> for pointing me out git, if he says something is good stuff&#8230; believe him <img src='http://www.pplux.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Other good links about what we&#8217;ve talked here:</p>
<p><a href="http://www.gnome.org/~federico/news-2008-11.html#27">http://www.gnome.org/~federico/news-2008-11.html#27</a><br />
<a href="http://markmcb.com/tag/workflow/">http://markmcb.com/tag/workflow/</a><br />
<a href="http://utsl.gen.nz/talks/git-svn/intro.html#howto-track-rebuildmeta">http://utsl.gen.nz/talks/git-svn/intro.html#howto-track-rebuildmeta</a><br />
<a href="http://www.viget.com/extend/effectively-using-git-with-subversion/">http://www.viget.com/extend/effectively-using-git-with-subversion/</a><br />
<a href="http://techbase.kde.org/Development/Tutorials/Git#Interfacing_KDE.27s_SVN_repository_with_git-svn">http://techbase.kde.org/Development/Tutorials/Git#Interfacing_KDE.27s_SVN_repository_with_git-svn</a><br />
<a href="http://live.gnome.org/GitForGnomeDevelopers">http://live.gnome.org/GitForGnomeDevelopers</a><br />
<a href="http://tsunanet.blogspot.com/2007/07/learning-git-svn-in-5min.html">http://tsunanet.blogspot.com/2007/07/learning-git-svn-in-5min.html</a><br />
<a href="http://blogs.gnome.org/johncarr/2008/06/21/git-mirrorgnomeorg/">http://blogs.gnome.org/johncarr/2008/06/21/git-mirrorgnomeorg/</a><br />
<a href="http://markmcb.com/2008/09/17/migrating-a-subversion-svn-project-and-server-to-git/">http://markmcb.com/2008/09/17/migrating-a-subversion-svn-project-and-server-to-git/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pplux.com/2008/11/26/from-subversion-to-git/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

