<?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>tensixtyone &#187; git</title>
	<atom:link href="http://tensixtyone.com/tags/git/feed" rel="self" type="application/rss+xml" />
	<link>http://tensixtyone.com</link>
	<description>Rants of Andrew Williams / Nik_Doof</description>
	<lastBuildDate>Fri, 25 Jun 2010 10:58:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Importing History into Git</title>
		<link>http://tensixtyone.com/perma/importing-history-into-git</link>
		<comments>http://tensixtyone.com/perma/importing-history-into-git#comments</comments>
		<pubDate>Wed, 15 Apr 2009 12:31:01 +0000</pubDate>
		<dc:creator>Andrew Williams</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://tensixtyone.com/?p=514</guid>
		<description><![CDATA[With my recent move over to Git for my VCS Home solution I decided to start afresh with new repositories and not migrating the history over, in the last few days i&#8217;ve noted that it was a very bad decision and having the full history will always be useful. Now i&#8217;m stuck in the situation [...]]]></description>
			<content:encoded><![CDATA[<p>With my recent move over to Git for my VCS Home solution I decided to start afresh with new repositories and not migrating the history over, in the last few days i&#8217;ve noted that it was a very bad decision and having the full history will always be useful. Now i&#8217;m stuck in the situation of two repos with different histories. How do you reconcile these two trees into one full history tree?</p>
<p>First of all we need a working Git version of your existing repo, in my case, it&#8217;s in SVN, so I used the git-svn tool to import my svn repository.</p>
<pre>$ cd ~/dev/
$ git svn clone http://tensixtyone.com/svn/home/trunk/bash</pre>
<p>Git then downloads each SVN commit and imports it, this can be quite slow on large repositories but thankfully mine was only 20 or so commits. Now you have your originally repository in Git format the few final steps will bring in the changes you have done in the new repository.</p>
<p>To import the history we are going to generate a set of diffs, while this sounds less than ideal it is really the only clean way to get your new commits into your old repository, attempting to pull the commits in will throw errors as the commit hashes will not match.</p>
<p>First of all you need to find out the hash of your first commit in your new repository</p>
<pre>$ cd ~/.dotfiles/bash
$ git log

...

commit ec508803a080f2146231fb4cd396cc18a2906a9b
Author: Andrew Williams
Date:   Sat Apr 11 02:32:07 2009 +0100

    Imported initial bash files</pre>
<p>Then generate the diffs since that initial commit</p>
<pre>$ git format-patch ec508803a080f2146231fb4cd396cc18a2906a9b..HEAD
0001-Added-bash_logout-file.patch
0002-Updated-bash-config-files.patch
0003-Updated-a-few-aliases.patch
0004-Updated-prompt-to-detect-if-we-re-using-vcsh.patch
0005-Fixed-nano-alias.patch</pre>
<p>Now you have your fresh diffs, you need to import them into your existing repository. In addition i&#8217;m importing these into a new branch.</p>
<pre>$ cd ~/dev/bash/
$ git branch new-bash
$ git am ~/*.patch</pre>
<p>The am command is mostly used to apply patches from a mailbox but for this case we can just tell it to use the patch files instead. After the command has completed you should be able to check git log and be able to see all the new commits.</p>
<p>Once your happy with the patches, it&#8217;s a case of switching to master and merging the changes.</p>
<pre>$ git checkout master
$ git merge new-bash</pre>
<p>One thing to note, after this process the commits will have different hashes, so it wont be a simple case of pushing to your remote repo. I&#8217;d only recommend doing this if you have to, i&#8217;m sure that a better proceedure exists but this is what worked for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://tensixtyone.com/perma/importing-history-into-git/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The version controlled home directory</title>
		<link>http://tensixtyone.com/perma/the-version-controlled-home-directory</link>
		<comments>http://tensixtyone.com/perma/the-version-controlled-home-directory#comments</comments>
		<pubDate>Mon, 13 Apr 2009 01:02:32 +0000</pubDate>
		<dc:creator>Andrew Williams</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[home]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[vcs home]]></category>

		<guid isPermaLink="false">http://tensixtyone.com/?p=499</guid>
		<description><![CDATA[For the last year or two i&#8217;ve been using SVN to store my common configuration files, this has worked wonders and has enabled me to move my config seamlessly between systems with a few simple commands. In the last day or so i&#8217;ve decided to move from SVN to Git as my control system, and [...]]]></description>
			<content:encoded><![CDATA[<p>For the last year or two i&#8217;ve been using SVN to store my common configuration files, this has worked wonders and has enabled me to move my config seamlessly between systems with a few simple commands. In the last day or so i&#8217;ve decided to move from SVN to Git as my control system, and now I think it&#8217;s a time to do a post on why exactly i&#8217;m doing this.</p>
<p>The idea of a version controlled home directory stemmed from people storing their /etc config files in CVS, this allowed for any modifications to be tracked, tested, and if worse came to worse, rolled back without much hassle. These ideas can be very useful for the end user, imagine you want to fiddle around with your terminal settings but forget to make a backup of your original settings, the time you spend trying to fix it back can be avoid with a simple vcs command. Another situation that I often get into is when you format or move to another system, a few quick commands can return your config and no pain of trying to remember your favourite settings.</p>
<p>So, how do we do this?</p>
<p>Each person has their own method, and hopefully I&#8217;ll describe my little world to everyone in a easily digestible way. It&#8217;s neither pretty or easy but it works for me.</p>
<p>My SVN version was very simplistic, a single repository broke down into &#8220;packages&#8221;, which contained the batch of config files for each program, such as &#8220;irssi&#8221; or &#8220;bash&#8221;, these would live under &#8220;trunk&#8221; in the repository.</p>
<pre>~/trunk
$ ls
abook          gtk2     ikog   keepass-private  mutt  ssh          tin
gnupg-private  hamachi  irssi  mozilla          pine  ssh-private  xchat</pre>
<p>For each machine I made a new branch under &#8220;branches&#8221; then I would use the &#8220;externals&#8221; properties to pull in the packages that I needed from trunk. So, when I wanted to pull in my configuration I would simply checkout that machine&#8217;s branch into a folder then symlink the required files over as needed.</p>
<pre>~/branches
$ ls
ithaca  manex  orion  vektor</pre>
<p>This took time to setup but once the initial linking was done it was a simple matter of managing the files in the single checkout folder.</p>
<p>This system served me well for a year or two, but with the increase of machines and the general pain of symlinks I decided I needed a new method. I reviewed a few examples but the one that stuck with me was <a href="http://lists.madduck.net/pipermail/vcs-home/2008-July/000147.html">Martin Krafft&#8217;s system</a> using Git, MR and a few handy scripts. I&#8217;ve now managed to rework this into a similar system for myself.</p>
<p>First of all, you need a method of getting the configuration files in the location you require. Git has this excellent feature to having detached worktrees, this allows you to remove the need for symlinking all together. For example, we can setup a git repository in a storage directory then tell the repo to checkout the files to your home directory.</p>
<pre>$ mkdir -p ~/.dotfiles/test.git
$ cd ~/.dotfiles/test.git
$ git init --bare
$ git config core.worktree ../../</pre>
<p>So now, you have the test.git repository, and the worktree is your home directory. Now it&#8217;s simply a case of checking in the files you require and commit them to the repo. This scenario is a little different from the original Git idea so a little bit of a workaround is needed to actually use the repo in this way. Two variables need to be configured for Git to use the detached worktree as desired.</p>
<pre>$ export GIT_DIR=~/.dotfiles/test.git
$ export GIT_WORK_TREE=~/.dotfiles/test.git/../../</pre>
<p>Now, you can use the Git command as if you were in a normal Git worktree. This is a pain to work with by hand but luckily Martin also created a little <a href="http://git.madduck.net/v/etc/zsh.git?a=blob;f=.zsh/func/vcsh">shell script</a> to set these variables as needed. It&#8217;s based on zsh but i&#8217;m in the process to converting this to bash to avoid a extra unneeded dependency on my part.</p>
<p>So, we can get the configuration files to the place they need to be, now we move onto actually packaging and distributing the files. I decided that Martin&#8217;s method works the best, using the <a href="http://kitenet.net/~joey/code/mr/">mr tool</a> you can configure and manage multiple repositories and automate the checkout and update of these. This with tool the management of your packages can be done by simply changing the config file of mr.</p>
<p>mr supports importing extra configuration files based on wildcards, this allows for a global configuration to be setup which will only include configuration on a per machine basis. For example in the current .mrconfig I have this.</p>
<pre>[DEFAULT]
include = cat ~/tools/mr/lib/* ~/.mr/* 2&gt;/dev/null || :</pre>
<p>Simply put, this will include any files in my ~/tools/mr/lib/ and ~/.mr/ folder. Then in my .mr folder I have a file for each type of package I have available</p>
<pre>[.dotfiles/mr.git]
checkout = git_fake_bare_checkout 'ssh://git.tensixtyone.com/mr.git' 'mr.git' '../../'

[.dotfiles/bash.git]
checkout = git_fake_bare_checkout 'ssh://git.tensixtyone.com/bash.git' 'bash.git' '../../'

[.dotfiles/bin.git]
checkout = git_fake_bare_checkout 'ssh://git.tensixtyone.com/bin.git' 'bin.git' '../../'

[.dotfiles/ssh.git]
checkout = git_fake_bare_checkout 'ssh://git.tensixtyone.com/ssh.git' 'ssh.git' '../../'</pre>
<p>So when I execute the mr command this will checkout each of those repositories as needed. If I require any extra packages I can pull in another config file and drop it into the .mr folder.</p>
<p>Now we have the method and the configuration sorted, how do we get this onto a bare machine? Again, Martin has come to the rescue in a form of a script he has setup to do the initial bootstrapping of a fresh account, it pulls in the basic configuration for mr and then it&#8217;s a case of dropping in the require config files into the .mr folder. Job done.</p>
<p>While my system isn&#8217;t perfect yet, it is workable and very flexible. The benefit of being able to move my active configuration between machines with a few commands outweighs the time needed to setup and configure the system. If you are interested my public configuration files are <a href="http://git.tensixtyone.com/">available</a> via gitweb, hopefully from the mass of files you can work out what i&#8217;m doing. For the bootstrapping script check the setup.git repository, for my mr configuration files check mr.git.</p>
<p>If your interested in setting up a version controlled home directory, I&#8217;d advise you to join the <a href="http://lists.madduck.net/listinfo/vcs-home">vcs-home mailing list</a> and check out their archives and wiki. Also, remember there&#8217;s no all ruling version control system to use for your home directory, Git works well for me but it doesn&#8217;t for everyone. The idea is to have a system that works for you, while I&#8217;ve followed Martin&#8217;s example very closely, again, this wont fit all.</p>
]]></content:encoded>
			<wfw:commentRss>http://tensixtyone.com/perma/the-version-controlled-home-directory/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
