Search code examples
eclipsegitegitignore

How to ignore a file already committed on GIT repository in Eclipse using EGit?


I try to ignore a committed ".project" file on Eclipse EGit, without deleting it from my Eclipse project nor the repo.

I have this need :

  • the ".project" file of my Eclipse project must be committed at least at the begining of the project, so that my co-workers can pull it when they will "build" their Eclipse workplace
  • this file could be modified by any of us, but should not be pushed on GIT repo
  • this file must stay on GIT repo all the time, because a co-worker could have to get back the project at any time
  • we are working on Windows, so using command-line is a bit off-subject : I seek for help on Eclipse EGit

We are migrating from SVN to GIT : on SVN, we did not had this kind of problem, because we could not commit some files. On GIT, it seems that we have to commit everything we modify so that we do not have conflicts.

Can anybody help me ?

Thank you !


Solution

  • Right-click the file and choose Team > Advanced > Assume Unchanged.

    See Eclipse Help - EGit Documentation - EGit User Guide - Reference:

    Resources can be flagged "assume unchanged". This means that Git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell Git when you change the working tree file. This setting can be switched on with the menu action Team > Assume unchanged and switched back with the menu action Team > No Assume unchanged.

    It should be noted that each co-worker must do this once. A server-side Git hook could reject commits changing .project if a co-worker had forgotten to do so.