简体   繁体   中英

GIT: How to add file to repo but ignore it for changes

I have a file with app configuration. I want to add this file to the repo so everyone could have basic configuration but ignore any changes in file if someone will want to modify configuration.

I know about assume-unchanged but it looks like it is only for local repo, when somebody will clone the repo and change this file git will mark it as modified.

Thanks.

Even if there is a technical solution to the problem, I don't think you should seek it. As a user of your repository, if I kept changing this one file and it wasn't showing up in my stage, I'd be very confused.

Mark the file as do not edit, either in a comment in the file, or in the readme if the file does not allow comments.

Then, if someone wants to make modifications to it and sees it in stage, it's their responsibility to set an ignore on the file.

  • Call your configuration config-template.conf and provide that through the repo.
  • In the README, instruct users to rename the template to config.conf which your application expects to find.
  • Add config.conf to your .gitignore .

The config.conf will not be tracked.

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