13

First of all, I've seen .vs\config\applicationhost.config in source control.

We are working in a team and Visual Studio changes some path inside applicationhost.config file. We need to exclude this. In my .gitignore file, I've added:

/.vs/config/applicationhost.config

However, in every commit, this is again added to the git. Before VS2015 Update 2, it was no issue, but something has changed to git integration with VS after this update and now it's being included. Whenever my workmates pull changes to the branch, their IIS Express fails because of the changes to this file (it has paths local to my own PC's paths etc.) and vice versa.

How do I pull this file out of the source control completely?

Community
  • 1
  • 1
Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389
  • Possible duplicate of [Ignore files that have already been committed to a Git repository](http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository) – MrTux May 11 '16 at 08:50

2 Answers2

19

Do you have applicationhost.config file already in repository before adding it to .gitignore file?

If so you need to use command git rm --cached [file].

Purpose of .gitignore file is to keep untracked files untracked, so it wont affect files that you already track.

EDIT:

As I totally forgot: Above solution works for repository, so all developers working will be forced to maintain their own copy.

To prevent git from detecting changes you should also use this: git update-index --assume-unchanged [path_or_file] And if - in future - you would want to start tracking changes again you'll need to revert update via: git update-index --no-assume-unchanged <file>

And to see files marked with --assume-uchanged flag you can use this: git ls-files -v | grep '^[[:lower:]]' See documentation for git ls-files.

I believe this blog entry can be more descriptive.

Konrad 'Zegis'
  • 15,101
  • 1
  • 16
  • 18
  • Did this, it removed the file from git. Then I've pushed, my friend pulled and the problem still continues. – Can Poyrazoğlu May 11 '16 at 08:53
  • There are two options now: you'r friend can maintain his/her own local copy by using the same instruction, or you could update index via: `git update-index --assume-unchanged`. I'll update answer in a second. – Konrad 'Zegis' May 11 '16 at 09:34
  • @CanPoyrazoğlu I'm not sure how notify'ing on SO works, so just in case: I updated answer. Hope it'll help! – Konrad 'Zegis' May 11 '16 at 15:37
7

Try the command:

git rm /.vs/config/applicationhost.config

Then commit changes to repository.

The line in .gitignore just give to git information, that this file should not be listed as "untracked files" in git status output

miodziu
  • 81
  • 3
  • Why did this get down voted? The file is generated by VS, deleting the file doesn't seem to make any issues for VS. Adding it to .gitignore and deleting it from the repository seems fine. Am I missing something? – Joseph McIntyre Dec 07 '16 at 15:45
  • Did a little more looking around and found this question. http://stackoverflow.com/questions/6313126/how-to-remove-a-directory-in-my-github-repository Which has better answers. – Joseph McIntyre Dec 07 '16 at 16:34