version-controlmercurialhgsubversion

Untrack files without removing from remote repository


In our company, we just started using Mercurial and we are facing the following problem:

We have some files in the remote repository that are changed by each developer to add some local configuration but these files must never be changed in the remote repository.

Is there a way to tell Mercurial to stop tracking those files locally without making any change to the file on the remote repository?

We tried with hg forget <file> but as I understand, this will remove the file from the remote repository.

We also tried adding those files to .hgignore file, but somehow the files are not really being ignored, I guess Mercurial does this because the files are already being tracked.

So far, we are just ignoring the files when we perform a commit and we use shelve to maintain and restore our local changes after an Update, but it's starting to be a really tedious task.

Thanks in advance for any help.

EDIT: Although it didn't completely fix what we wanted to, accepted answer is the best approach. Our problem is probably a result of a bad design.


Solution

  • If the file you want unchanged is, for example, config.cfg, check in a config_template.cfg, forget config.cfg if it is already tracked, and add config.cfg to the ignore list. Then, a build rule can create config.cfg from the template if it does not already exist.

    A user will then have a starting config.cfg that they can customize without checking it in.