How to prevent the removal of ignored files?

I version managed the project settings folder a couple of months ago in my default branch, and then over time created many branches with the default. Now I decided that I would prefer not to control the version of the project settings folder, since there are a lot of problems when switching between branches.

So, I have hg forget this project settings folder, which allows me to store files on my local machine, but deletes them due to mercury. However, when switching from one of the old branches that still have this folder, returning to the default branch, it actually deletes the files from the local machine, which is bad.

How to prevent this?

Now the folder is also in .hgignore by default.

0
source share
2 answers

This is impossible to do.

But a common practice is to save config.ini.dist in your repository and build a specific configuration for a specific environment by some kind of prefabricated system immediately after checking the source code.

+2
source

The standard way to deal with this is to manage versions of the template configuration file and ignore the actual configuration file. The present configuration file may include a template file, or perhaps the template file is copied once at a time.

The main cause of your problems is the launch:

 $ hg forget config.ini 

exactly the same as it works:

 $ hg remove config.ini $ hg cat config.ini > config.ini 

The team forgets to leave the file in your working directory, but what you did is still delete the file. This means that subsequently Mercurial cannot distinguish between “the file was forgotten” and “the file was deleted” - only the deletion is completed, so the two commands look exactly the same.

+1
source

Source: https://habr.com/ru/post/1380834/


All Articles