处理私有和公共存储库的技术?
我有一个开源网站。有些内容是“私有的”,例如连接参数,以及开源版本不需要的文件(例如广告模板)。
本质上,我试图维护两个版本:
- 具有唯一身份的公共网站(广告、Google Analytics 帐户、关联论坛的链接等)
- 用于社区开发的开源版本,没有不必要的依赖项或品牌
目前我正在使用 .gitignore 文件来防止“私有”内容被推送到开源存储库。附带一个帮助程序,其中包含本地找到的模板,但对于开源版本显示一个空框。
这工作得很好,直到我尝试在功能分支之间进行签出:分支可能需要设置文件中的新密钥。由于设置文件被 Git 忽略(以避免推送密码等),因此站点崩溃了。
理想情况下,我想要对设置文件进行版本控制,但能够告诉 Git 不要将这些文件推送到远程服务器 (Github)。这可能吗?
我应该使用分支来管理不同的网站版本吗?
I have an open source'd website. Some content is "private" such as connection parameters, as well as files that the open source version doesn't need (eg. advertising templates).
Essentially I'm trying to maintain two versions:
- A public site that has a unique identity (advertising, Google Analytics account, link for associated forum and so on)
- An open source version for community development, without unnecessary dependencies or branding
Currently I'm using a .gitignore file to prevent the "private" content to be pushed to the open source repository. Along with a helper that includes templates that are found locally, but shows an empty box for the open source version.
This works well enough until I try to checkout between feature branches: a branch may need a new key in the settings file. Because the settings file is ignored by Git (to avoid push'ing passwords and so on), the site breaks.
Ideally I'd want to version control settings files, but to be able to tell Git not to ever push these files to a remote server (Github). Is that possible?
Should I use branches to manage different website versions instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用git子模块:
一个存储库内的分支并不是答案,尤其是在处理敏感信息时。
You should use git submodules with:
Branches within one repo is not the answer, especially when dealing with sensitive informations.
分支(正如您所建议的)可能是最直接的方法。事实上,这就是他们的目的,即将多个项目/版本彼此分开。
Branches (as you suggested), is probably the most direct way to do this. In fact this is what they were meant to do, namely to separate multiple projects/versions from each other.