tags:

views:

2535

answers:

3

Here is a simple question.

I have cloned a project that includes some .csproj files.

I don't need/like my local csproj files being tracked by git (or being brought up when creating a patch), but clearly they are needed in the project.

I have added *.csproj to my LOCAL .gitignore, but the files are already in the repo.

When I type git status, it shows my changes to csproj which I am not interested in keeping track of or submitting for patches.

Naive question: How do I remove the "tracking of" these files from my personal repo (but keep them in the source so I can use them) so that I don't see the changes when I do a status (or create a patch).

Correct question: (Out of curiosity, please answer the naive one as well): What is the correct/canonical way to handle this situation?

Thanks so much.

+20  A: 

Just calling "git rm --cached" on each of the files you want to remove from revision control should be fine. As long as your local ignore patterns are correct you won't see these files included in the output of git status.

anthony
According to the manual: git-rm - Remove files from the working tree and from the indexThat is exactly what I don't want to do. Am I missing something?However, looking at the documentation for git rm, I see --cached--cached: Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.I think that is what I need, right?
"git rm --cached <file>" would remove <file> from version control, while keeping it in the working repository. Whether it is what you want...
Jakub Narębski
yeah good call on --cached. i'm so used to having most build related files be generated. I'll edit my response.
anthony
+3  A: 

If you do "git update-index --assume-unchanged file.csproj", git won't check file.csproj for changes automatically: that will stop them coming up in git status whenever you change them. So you can mark all your .csproj files this way- although you'll have to manually mark any new ones that the upstream repo sends you. (If you have them in your .gitignore or .git/info/exclude, then ones you create will be ignored)

I'm not entirely sure what .csproj files are... if they're something along the lines of IDE configurations (similar to Eclipse's .eclipse and .classpath files) then I'd suggest they should simply never be source-controlled at all. On the other hand, if they're part of the build system (like Makefiles) then clearly they should--- and a way to pick up optional local changes (e.g. from a local.csproj a la config.mk) would be useful: divide the build up into global parts and local overrides.

araqnid
A: 

My answer is not really an answer, but further question.

Anthony, thanks for the reply. I get the logic of git rm --cached , but when you do that, the file gets tracked as deleted, so if u commit and push u stop tracking it from the remote repo as well. I don't want that.

For example, I have a database config file, that I want all my users to pull from the main repo. But I'd like each one to exclude it from the $GIT/info/exclude (locally) so they don't push it by mistake or something. OK, but ones the file is tracked, it alerts for modifications after the user has adjusted his/hers local DB settings in the database file. So as you are saying, if the users git rm --cached path/to/db.config, on git status it will show the file as deleted. So still not a solution for me.

Any ideas?

Thank you

maybe you "git mv" it to a different location, then commit, then copy it only in the file system back where it was, then "git remove" the different location? just a quick shot.