<?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>Abizern.org &#187; config</title>
	<atom:link href="http://abizern.org/tag/config/feed/" rel="self" type="application/rss+xml" />
	<link>http://abizern.org</link>
	<description>The personal and developer blog of a Mac developer in London.</description>
	<lastBuildDate>Thu, 02 Sep 2010 01:47:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Three ways of excluding files from git</title>
		<link>http://abizern.org/2010/02/07/three-ways-of-excluding-files-from-git/</link>
		<comments>http://abizern.org/2010/02/07/three-ways-of-excluding-files-from-git/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 18:52:32 +0000</pubDate>
		<dc:creator>Abizer</dc:creator>
				<category><![CDATA[Mac Development]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[exclude]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[ignore]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://abizern.org/?p=278</guid>
		<description><![CDATA[Almost every git user knows about adding a .gitignore file to their repository to control the visibility of files and folders. This per project configuration will apply to all repositories of the same code base. But it’s not the only way. I’m going to tell you how to get git to ignore files on a [...]]]></description>
			<content:encoded><![CDATA[<p>Almost every git user knows about adding a <code>.gitignore</code> file to their repository to control the visibility of files and folders. This per project configuration will apply to all repositories of the same code base. But it’s not the only way. I’m going to tell you how to get <a title="http://git-scm.com" href="http://git-scm.com">git</a> to ignore files on a per computer and per repository basis. These could be better choices in some circumstances.</p>
<p>There are three types of exclude files; from highest to lowest order of precedence they are:</p>
<h2>Per Project: .gitignore file in the repository</h2>
<p>This is the usual way of adding an ignore file. Call it <code>.gitignore</code> and save it to the root of your project to apply to all the files (you can add different <code>.gitignore</code> files in subdirectories where they have lesser scope). It is a part of the repository, so it will need to be <code>git-add</code>ed and committed for each change. This is useful for repositories that are passed around with others who may not have a per computer exclude file, or when there are project specific files that need to be taken into account. Even easier if you have per computer file, you can copy it straight in to your project with a simple <code>cp ~/.gitignore .gitignore</code> and edit to handle your specific requirements.<br />
<h2>Per Repository: in .git/info/excludes</h2>
<p>You can exclude files on a per repository basis by editing the <code>.git/info/excludes</code> file in your repository. (Why it takes it from this location rather than <code>.git/config</code> I don’t know: add it to the list of git annoyances). These exclusions (or inclusions, you can override the higher level exclusions by prepending <code>!</code> to lines that you want to include) are not shared with the working directory, so they only apply to that particular repository. This is useful when you have particular requirements because of your workflow or machine setup.</p>
<h2>Per Computer: through ~/.gitconfig settings</h2>
<p>There should already be a <code>.gitconfig</code> file in your home directory. This is where the global setting for your git installation are stored; such as the user’s name and email address. Within this you can set a path to an excludes file that will apply to all git repositories on the computer in the same way as the name and email defined in this file apply to all repositories.</p>
<p>For example: Most of what I do is in <a title="Apple's Xcode site" href="http://developer.apple.com/tools/xcode/">Xcode</a> so I have the following ~/.gitignore file</p>
<div class="code">
<p># ~/.gitignore</p>
<p>*.DS_Store<br />
*.pbxuser<br />
*.mode1v3<br />
*.mode2v3<br />
*.perspectivev3</p>
</div>
<p>And in my <code>.gitconfig</code> file under the <code>[core]</code> section I have added the path to this file for the <code>excludesfile</code> key. (If you’re sharp eyed, you’ll notice that I don’t have an exclusion for <code>/build</code>. That’s because I don’t keep my products in my project directory, but that’s for a different post).</p>
<div class="code">
<p>&lt;snip&gt;…<br />
<span style="color: #dd0000;">[</span><span style="color: #003369;">core</span><span style="color: #dd0000;">]</span><br />
editor = /usr/bin/see -w -r -o new-window -j ‘git editor’ -m gitCommit -g 1:0<br />
excludesfile = /Users/abizern/.gitignore<br />
&lt;snip&gt;…</p>
</div>
<p>Now, I have a standard set of ignores that apply to all my git repositories on this machine without me having to add a specific <code>.gitignore</code> file to each one. This is probably most useful if you create a lot of repositories for yourself, but I recommend it to everyone. It’s lowest on the precedence scale and provides a neat catch-all.</p>
<h2>Summary</h2>
<p>Most of the time the first solution is quite adequate, having exclusions with a repository that is likely to have a public face is probably the most effective way of managing file visibility. But, as with most of git, there are ways of handling edge cases. You just need to know that they are there.</p>
<p><strong>REFERENCE:</strong> the <a title="gitignore(5) Man page on git-scm.com" href="http://www.kernel.org/pub/software/scm/git/docs/gitignore.html">gitignore</a> man page.</p>
]]></content:encoded>
			<wfw:commentRss>http://abizern.org/2010/02/07/three-ways-of-excluding-files-from-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
