简体   繁体   中英

How to keep local versioned files in Mercurial

I have a config file that is versioned, lets call it Web.Config. I want to be able to keep the original versioned file in the repo as a template, but maintain my locally modified version through pulls, fetches, merges, etc. Is this possible in Mercurial?

This has been asked/answered here quite often, but I'll bite:

The way to do this is to keep a version in the repository that's a template and keep your actual modified version local-only and listed in .hgignore. For example keep the file app.config.sample in the repo and have your build / launch scripts look for app.config , which is listed in the .hgignore . If you want to get fancy you can even have your launch/build scripts copy the sample file to the actual file if it doesn't exist when run.

In short, there is no good way to have a file both tracked (added) and untracked (changes aren't committed) at the same time unless you want to do it manually using commands like hg commit -I app.config , which even with aliases, you'll eventually forget.

You can:

  • Create local-only customized config in MQ-patch (rename or copy template, apply needed changes to local config), apply patch for local work, unapply before push (or use secure phase for patches and they will not be published even if applied)
  • Build customized local config in local branch (ordinary named branch, which must be never merged to default , you merge only default to local branch ) and always use push -b default (directly or as alias-command): because local branch haven't ancestors for default's head, it will not be pushed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM