views:

89

answers:

2

I'm using Git with WindRiver to manage a project of mine. The code is being managed, however the project files (such as .cproject, .project, .wrmakefile, and .wrproject) are not. However when I switch branches, Git deletes those files spite them being in .gitignore, thereby removing my ability to compile the code without having to revert commits or keeping a backup.

So, is there a way to say to Git - ignore these files and don't touch them no matter what?

+1  A: 

I'm not an expert in GIT, but it sounds like you commited your dot files before you added them into gitignore and before you branched. This is how I resolve these issues (there might be a better way to do this).

I copy the files outside of the git repo, then run git rm <files> to delete the files out of the repo, add the appropriate entries into gitignore, then copy the files back into the project.

digitaldreamer
I did commit them before I added them to git ignore, but I did do a `git rm --cached <files>` so I don't have to copy them and replace them.Though I did not edit any part of the .gitignore in the branch. I was just trying it out first in master. Would this have affected this?
Tanner
Did you run git rm before or after you added them to gitignore? I don't think git will manage ignored files.
digitaldreamer
+2  A: 

This should do the trick:

  1. Remove the files from .gitignore
  2. Delete the files with git rm (make a backup if you have to) and commit
  3. Add the files to .gitignore again and commit

Remember, you'll probably have to do this for every branch, either manually or by pulling the commits from the master branch.

elektronaut
how does that work???
hasen j
The files are still in the git repo, .gitignore simply ignores any changes to them.
elektronaut
Use `git rm --cached` to remove them only from the index, not the work tree.
Jefromi