Is there a way to “freeze” a file in Git?

后端 未结 5 1364
鱼传尺愫
鱼传尺愫 2020-12-23 14:40

I\'m in a situation where I want to open source my project, however there\'s a single source file that I want to release a \"clean\" version of, but use a separate version l

5条回答
  •  再見小時候
    2020-12-23 15:40

    I've solved a similar situation like this for config files in Django by using symbolic links. It seems you're looking for versioning capabilities instead of config file management, but I'm sure this little strategy could help. Here are the steps I usually take:

    Say the file you want to update locally (and not to be shared) is named 'local.file' and the file that you want released (in the wild) is 'release.file'... You need to create a symbolic link file, let's call this symbolic link file 'actual.file'. The symbolic link file will either point to local.file or release.file at any given time (or be missing if you just cloned the repo).

    1. gitignore local.file and actual.file so they aren't tracked since you don't want these to be kept track of or released. actual.file is always pointing to the file that you want to work with.
    2. Make the symbolic link point to local.file when you're working on your 'non-frozen' version-ed file.
    3. Make the symbolic link (actual.file) point to 'frozen' release.file when you want to make manual updates on it or simply copy changes from local.file to release.file.

提交回复
热议问题