removing files part of a later-added git ignore

Dear Future Jamie

When you add a gitignore to an existing project, to force git to release the files you don’t want, run the following from the directory where the project is located (note the extra period at the end of the 2st two commands)

1 git rm -r –cached . 2 3 git add . 4 5 git commit -am "Remove ignored files" 6


Past Jamie

Using Git With Visual Studio

I am starting to use Git with Visual Studio 2013 on my home projects.  I have been using Git lightly for pushing code samples into GitHub, but never on projects with other people.  This is a pretty good set of articles about setting up Git with Visual Studio and well worth the read before doing it (like who reads instructions). 

I created a project on Visual Studio Online and selected Git as the source control.  I then cloned the empty project locally.  Next, I created a brand-new Web Api 2 solution in Visual Studio and pushed the files over to that repository.  I then pushed those changes up to VSO.  Finally, I went over to another machine and cloned the repository and pulled down the files.

This was all well and good until I made a change on one machine and I wanted to pull down the changes into the solution that I had open on the other machine.  I was getting an “uncommitted changed being overwritten by merge” exception.  The frustrating thing was that there was nothing in the Visual Studio 2013 tooling/add-ins that allowed me to discard my local changes.  I wrote this post to stack overflow and it turns out I had a problem because I made the mistake of adding file to the repository that I didn’t want to.  I needed to do this –> add the .suo file to gitIgnore BEFORE committing the 1st change.  The problem was that adding it to the gitIgnore after the commit means the file was still being tracked and there is nothing in the out of the box VS2013 tools that can help you resolve the problem. 

The best advice from SO was to use git extensions because when I installed it, I could do all of the things I wanted to do without learning the git commands.  Indeed, I installed it and holy cow, this is awesome: