title: Git excludesfile for a branch
body: <p>I want to ignore certain files within a branch without having to rely on a tracked <code>.gitignore</code> file that will be overwritten during merges with other branches.</p>
  
  <p>I’ve closely followed <a href="https://stackoverflow.com/questions/1836742">a Stack Overflow answer</a> along with <a href="http://cogniton-mind.tumblr.com/post/1423976659/howto-gitignore-for-different-branches" rel="noreferrer">the linked blog post</a>, but my repo doesn’t seem to be recognizing the specified <code>excludesfile</code> in my <code>.git/config</code>. The Git documentation (<a href="https://www.kernel.org/pub/software/scm/git/docs/git-config.html#Syntax" rel="noreferrer"><code>git-config</code></a>, <a href="http://git-scm.com/docs/gitignore" rel="noreferrer"><code>gitignore</code></a>) doesn’t seem to show how to specify and address an excludes file for a specific branch.</p>
  
  <p>My <code>.git/config</code> looks like this:</p>
  
  <pre><code>[core]
          repositoryformatversion = 0
          filemode = true
          bare = false
          logallrefupdates = true
          ignorecase = true
          precomposeunicode = true
          excludesfile = +/info/exclude
  
  [branch "myspecialbranch"]
          excludesfile = +/info/exclude_specialbranch
  </code></pre>
  
  <p>My <code>.git/info/exclude</code> file looks like this (by default, I didn’t touch it):</p>
  
  <pre><code># git ls-files --others --exclude-from=.git/info/exclude
  # Lines that start with '#' are comments.
  # For a project mostly in C, the following would be a good set of
  # exclude patterns (uncomment them if you want to use them):
  # *.[oa]
  # *~
  .DS_Store
  </code></pre>
  
  <p>I don’t have a <code>.gitignore</code> file in my “specialbranch”.</p>
  
  <p>If I try to ignore a file like <code>info.php</code>, my <code>.git/info/exclude_specialbranch</code> file looks like this:</p>
  
  <pre><code>info.php
  </code></pre>
  
  <p>… but it doesn’t ignore the file.  </p>
  
  <p>If I run <code>git status --ignored</code>, it only lists the <code>.DS_Store</code> file from the default <code>exclude</code> file.</p>
  
  <p>However, if I add <code>info.php</code> to my <code>.git/info/exclude</code> file:</p>
  
  <pre><code># git ls-files --others --exclude-from=.git/info/exclude
  # Lines that start with '#' are comments.
  # For a project mostly in C, the following would be a good set of
  # exclude patterns (uncomment them if you want to use them):
  # *.[oa]
  # *~
  .DS_Store
  info.php
  </code></pre>
  
  <p>it ignores the file perfectly.</p>
  
  <p>Note that it still works without the line <code>excludesfile = +/info/exclude</code> under <code>[core]</code> in <code>.git/config</code>. Git seems to know where the system-wide <code>exclude</code> is without me having to tell it.</p>
  
  <p>I have a feeling that <code>.git/config</code> isn’t recognizing the address of my custom excludes file:</p>
  
  <pre><code>excludesfile = +/info/exclude_specialbranch
  </code></pre>
  
  <p>… most likely because of the use of <code>+</code> to describe the location of the <code>.git</code> directory.</p>
  
  <p>What’s the correct method for addressing custom exclude files in the (more recent) versions of Git?</p>
  
  <p>I’m running OSX 10.9.5 and Git version 2.2.1.</p>