title: git checkout gh-pages branch has files from master branch
body: <p>I have a repository with a Laravel App I'm working on which has master and gh-pages branches.</p>
  
  <p>When I do</p>
  
  <pre><code>git checkout gh-pages
  </code></pre>
  
  <p>Everything works but two directories 'app' and 'vendor' from the master branch show up. In the gh-pages branch I added them both to .gitignore just to make sure they don't get pushed up to the gh-pages remote branch. But then I decided to try deleting the vendor directory. When I switched back to the master branch the vendor directory was gone so I had to run composer install to get it back.</p>
  
  <p>Then I tried cloning the repository over again, fetching the gh-pages branch and the same problem occurs.</p>
  
  <p>ignoring them in the gh-pages branch works but they don't belong there so I'm confused as to why they are there. These are the only two directories that appear in both branches. </p>
  
  <p>You can see looking at the repo on github <a href="https://github.com/isimmons/office-twit" rel="nofollow">https://github.com/isimmons/office-twit</a> that these directories are not there so I don't understand why they are there in my local cloned repo.</p>
  
  <p>UPDATE: Starting with a clean clone of the repo here is a complete listing of the cli output. Something happened that made the /app directory go away in gh-pages branch but the problem is still there with the /vendor directory.</p>
  
  <pre><code>C:\Users\lotus\projects
  λ git clone git@github.com:isimmons/office-twit.git
  Cloning into 'office-twit'...
  remote: Counting objects: 470, done.
  remote: Compressing objects: 100% (254/254), done.
  rRemote: Total 470 (delta 190), reused 458 (delta 178)
  Receiving objects: 100% (470/470), 946.23 KiB | 460.00 KiB/s, done.
  Resolving deltas: 100% (190/190), done.
  
  C:\Users\lotus\projects
  λ cd office-twit\
  
  C:\Users\lotus\projects\office-twit (master)
  λ ls
  app      bootstrap      composer.lock    phpunit.xml  readme.md   upgrade.md
  artisan  composer.json  CONTRIBUTING.md  public       server.php
  
  C:\Users\lotus\projects\office-twit (master)
  λ git remote
  origin
  
  C:\Users\lotus\projects\office-twit (master)
  λ git branch
  * master
  </code></pre>
  
  <p>Everything is good at this point. Double checked to make sure all I have is 'origin' remote with 'master' branch and the /vendor directory is missing as it should be.</p>
  
  <p>Before pulling in the gh-pages branch I do a 'composer update' which adds the /vendor directory.</p>
  
  <pre><code>C:\Users\lotus\projects\office-twit (master)
  λ composer update
  Loading composer repositories with package information
  Updating dependencies (including require-dev)
    - Installing intouch/newrelic (dev-master aca23cc)
      Loading from cache
  
    - Installing symfony/translation (2.4.x-dev 0919e0f)
      Loading from cache
  
      . . . many more packages install . . .
  
  Generating autoload files
  Generating optimized class loader
  </code></pre>
  
  <p>Listing the contents of the directory I see /vendor as I should at this point, and git status shows a clean directory as it should because /vendor is in the .gitignore file.</p>
  
  <pre><code>C:\Users\lotus\projects\office-twit (master)
  λ ls
  app      bootstrap      composer.lock    phpunit.xml  readme.md   upgrade.md
  artisan  composer.json  CONTRIBUTING.md  public       server.php  vendor
  
  C:\Users\lotus\projects\office-twit (master)
  λ git status
  # On branch master
  nothing to commit, working directory clean
  </code></pre>
  
  <p>Next I checkout and track the gh-pages branch so what I have locally should be identical to what is on the remote (origin).</p>
  
  <pre><code>C:\Users\lotus\projects\office-twit (master)
  λ git checkout -b gh-pages origin/gh-pages
  Branch gh-pages set up to track remote branch gh-pages from origin.
  Switched to a new branch 'gh-pages'
  </code></pre>
  
  <p>As you can see somehow the /vendor directory shows up in the gh-pages directory though on the remote viewing gh-pages branch at <a href="https://github.com/isimmons/office-twit/tree/gh-pages" rel="nofollow">https://github.com/isimmons/office-twit/tree/gh-pages</a> the directory does not exist. So this is happening locally.</p>
  
  <pre><code>C:\Users\lotus\projects\office-twit (gh-pages)
  λ ls
  assets  index.html  README.md  vendor
  
  C:\Users\lotus\projects\office-twit (gh-pages)
  λ git status
  # On branch gh-pages
  # Untracked files:
  #   (use "git add &lt;file&gt;..." to include in what will be committed)
  #
  #       vendor/
  nothing added to commit but untracked files present (use "git add" to track)
  </code></pre>
  
  <p>I don't want to push gh-pages at this point because /vendor doesn't belong there and while adding /vendor to .gitignore will keep it from being tracked, it shouldn't be there at all.</p>
  
  <p>If I delete /vendor while in the gh-pages branch, then git status shows a clean working directory but then when I change back to the master branch /vendor has been deleted there too.</p>
  
  <pre><code>C:\Users\lotus\projects\office-twit (gh-pages)
  λ rm -rf vendor
  
  C:\Users\lotus\projects\office-twit (gh-pages)
  λ git status
  # On branch gh-pages
  nothing to commit, working directory clean
  
  C:\Users\lotus\projects\office-twit (gh-pages)
  λ git checkout master
  Switched to branch 'master'
  
  C:\Users\lotus\projects\office-twit (master)
  λ ls
  app      bootstrap      composer.lock    phpunit.xml  readme.md   upgrade.md
  artisan  composer.json  CONTRIBUTING.md  public       server.php
  </code></pre>
  
  <p>LAST UPDATE: I just figured out why the /app directory was there before. When I have the local repo opened for editing in SublimeText even if the master branch is clean, then change to the gh-pages branch, /app re-appears in that branch. This wasn't happening above because I was strictly using the cli. So the solution to that part of the problem is to completely close the /app directory before switching branches. </p>