title: Using git, how do I ignore a file in one branch but have it committed in another branch?
body: <p>I've got a project that I'm deploying to <a href="http://heroku.com" rel="noreferrer">Heroku</a>.  The source code tree includes a bunch of mp3 files (the website will be for a recording project I was heavily involved with). </p>
  
  <p>I'd like to put the source code for it up on <a href="http://github.com" rel="noreferrer">GitHub</a>, but GitHub has a 300 MB limit on their free accounts.  I don't want to use 50 MB of my limit on a bunch of mp3 files.  Obviously, I could add them to the <code>.gitignore</code> file to keep them out of my repo.</p>
  
  <p>However, I deploy to Heroku using <code>git push heroku</code>.  The mp3 files must be present in the branch I push to Heroku so that they get get deployed.</p>
  
  <p>Ideally, I'd like to <code>.gitignore</code> the mp3 files in my local master branch so that when I push that to GitHub, the mp3s are not included.  Then I'd keep a local production branch that has the mp3s committed rather than ignored.  To deploy, I would merge master into production, and then push the production branch to Heroku.</p>
  
  <p>I can't get this to work right.</p>
  
  <p>Here's an example of what I'm trying to do...</p>
  
  <pre><code>$ git init git-ignore-test
  $ cd git-ignore-test
  $ echo "*.ignored" &gt;&gt; .gitignore
  $ git add .gitignore &amp;&amp; git commit -m "Ignore .ignored files"
  $ touch Foo.ignored
  </code></pre>
  
  <p>At this point, Foo.ignored is ignored in my master branch, but it's still present, so my project can use it.</p>
  
  <pre><code>$ git checkout -b unignored
  $ cat /dev/null &gt; .gitignore
  $ git add Foo.ignored .gitignore &amp;&amp; git commit -m "Unignore .ignored files"
  </code></pre>
  
  <p>Now I've got a branch with these files committed, as I want.  However, when I switch back to my master branch, Foo.ignored is gone.</p>
  
  <p>Anyone got any suggestions for a better way to set this up?</p>
  
  <p>Edit: just to clarify, I want the mp3 files to be present in both branches so that when I run the site locally (using either branch) the site works.  I just want the files ignored in one branch so when I push to GitHub they are not pushed as well.  Usually .gitignore works well for this kind of thing (i.e. keeping a local copy of a file that does not get included in a push to a remote), but when I switch to the branch with the files checked in, and then back to the branch with the files ignored, the files vanish.</p>