如何停止跟踪文件,而无需将其从回购中移除 [英] How to stop tracking a file without removing it from repo

查看:128
本文介绍了如何停止跟踪文件,而无需将其从回购中移除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个配置文件,我想保留在远程存储库中,但我不想在我的计算机上跟踪其更改。将它添加到.gitignore中并不能解决问题。



我不想跟踪更改的原因是因为计算机根据环境的不同会有所不同。 如果是这种情况,那么你不应该有文件版本;你应该版本的文件模板。例如,如果配置文件是 foo / config.txt 那么你应该有一个版本化的 foo / config.txt.template foo / config.txt 根本不应该在存储库中,并且应该被 .gitignore 忽略。 p>

然后,在一个新克隆中,您只需将 foo / config.txt.template 复制到 foo / config.txt 并根据需要更改设置。


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 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.

Then, in a new clone, you just copy foo/config.txt.template to foo/config.txt and alter the settings as appropriate.

这篇关于如何停止跟踪文件,而无需将其从回购中移除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆