如何停止跟踪文件,而无需将其从回购中移除 [英] How to stop tracking a file without removing it from repo
问题描述
我有一个配置文件,我想保留在远程存储库中,但我不想在我的计算机上跟踪其更改。将它添加到.gitignore中并不能解决问题。
我不想跟踪更改的原因是因为计算机根据环境的不同会有所不同。 如果是这种情况,那么你不应该有文件版本;你应该版本的文件模板。例如,如果配置文件是 然后,在一个新克隆中,您只需将 I have a config file which I want to keep on the remote repository, but I don't want to track its changes on my computer. Adding it to .gitignore doesn't do the trick. The reason I don't want to track changes is because it's supposed to differ between computers depending on their environment. If that's the case then you shouldn't have the file versioned at all; you should version a template of the file. For example, if the configuration file is Then, in a new clone, you just copy 这篇关于如何停止跟踪文件,而无需将其从回购中移除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! foo / config.txt
那么你应该有一个版本化的 foo / config.txt.template $ c $在存储库中使用示例(或空白)配置设置。
foo / config.txt
根本不应该在存储库中,并且应该被 .gitignore
忽略。 p>
foo / config.txt.template
复制到 foo / config.txt
并根据需要更改设置。foo/config.txt
then you should have a versioned foo/config.txt.template
in the repository with example (or blank) configuration settings. foo/config.txt
should not be in the repository at all, and should be ignored with .gitignore
.foo/config.txt.template
to foo/config.txt
and alter the settings as appropriate.