I have a git repo at the workspace level. i.e. multiple closely related Eclipse projects in one repo.
If I add .metadata to .gitignore then each time I create new branch and checkout I loose my .metadata file and therefore import all the projects manually. This is unpleasant.
Is it safe to store the .metadata file under version control? This is a multi-developer project and JDK versions and perhaps even OSs (in future) may vary. (We’re all on Ubuntu at present.)
Are there any other IDE files which shouldn’t be comitted?
Thanks,
Chris.
The problem is that the file and/or directory was already tracked by git before you added it to
.gitignore:This means, among others, that if you have a file
fwhich is untracked in branchb1but you checkout branchb2in which this file is tracked, git will remorselessly overwritef.As mentioned in the previous question, the solution to make git completely ignore such files after “the harm is done” consists of issuing
git rm -r --cachedand only then adding them to .gitignore. But this needs to be done branch by branch, which means you will still have the problem in the meantime.Given your situation, you have two choices:
.metadataimmediately into.gitignore— and commit that first, before even committing the rest;git filter-branch.As to other files to ignore with other IDEs, I can only tell for IDEA:
.ideaand*.iml. No idea for others…