处理私有和公共存储库的技术?

发布于 2024-08-24 18:52:34 字数 459 浏览 4 评论 0原文

我有一个开源网站。有些内容是“私有的”,例如连接参数,以及开源版本不需要的文件(例如广告模板)。

本质上,我试图维护两个版本:

  • 具有唯一身份的公共网站(广告、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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我的影子我的梦 2024-08-31 18:52:34

您应该使用git子模块

  • 一个模块适用于所有公共内容,可以随意推/拉
  • 私有内容的一个模块,
  • 一个超级项目,也在一个私有存储库中,它引用公共子模块和私有子模块。

一个存储库内的分支并不是答案,尤其是在处理敏感信息时。

You should use git submodules with:

  • one module for all the public content, which can be pushed/pulled at will
  • one module for the private content
  • one super-project, also in a private repo, which references both the public and the private submodules.

Branches within one repo is not the answer, especially when dealing with sensitive informations.

活雷疯 2024-08-31 18:52:34

分支(正如您所建议的)可能是最直接的方法。事实上,这就是他们的目的,即将多个项目/版本彼此分开。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文