如何在嵌入式库上工作?

发布于 2024-12-04 03:39:48 字数 385 浏览 2 评论 0原文

这里是你的普通 Git 新手。

有时我发现自己正在为我选择的 PHP 框架 CodeIgniter 开发内置库。库中的删除是指人们只需将其复制到新的框架安装中即可轻松执行特定任务的东西。理想情况下,它不应覆盖任何框架的文件。

现在我希望 GitHub 存储库的 master 分支仅包含该库的文件。不过,我想维护一个开发分支,我将在该分支上...开发库。问题是,如果没有框架,我就无法开发库,因此开发分支也应该有框架。现在,由于配置框架涉及所有敏感数据(例如数据库访问),我不想将此分支推送到 GitHub 上。但是,鉴于我已经从 master 分支创建了开发分支,如何将我处理的文件“提取”到 master 分支呢?我有点困惑。

在这种情况下,推荐的工作流程是什么?我该怎么办?

提前致谢。

Your average Git newbie here.

Sometimes I find myself developing drop in libraries for my PHP framework of choice, CodeIgniter. A drop in library is something that one can just copy into a fresh framework installation to be able to easily perform a specific task. Ideally it shouldn't overwrite any of the framework's files.

Now I would like the master branch of my GitHub repository to only contain the library's files. However I'd like to maintain a development branch on which I'll... develop the library. The problem is that I can't develop a library without the framework around it so the development branch should have the framework in it too. Now, because of all the sensitive data involved in configuring the framework (eg. for database access) I wouldn't like to push this branch on GitHub. But how do I "extract" the files I worked on to the master branch given that I've created the development branch from the master branch? I'm a little confused.

What's the recommended workflow in this case? How should I go about it?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

爱要勇敢去追 2024-12-11 03:39:48

两种解决方案:

1/ 在开发分支上工作时修改索引,以便永远不会考虑修改的敏感文件

    git update-index --assume-unchanged my/sensitive/file

2/ 使用过滤器驱动程序来生成敏感文件;

在此处输入图像描述

  • 模板文件(版本化)
  • 值文件(未版本化)

请参阅“如何在我的本地和 github 存储库中保留一个文件的不同内容?


第三种解决方案是将您的 dropin 库与框架隔离在一个单独的存储库中,并仅使用框架存储库来部署您的磁盘特定版本,然后直接在复制的框架内签出您的 dropin lib 存储库。

您还可以通过子模块链接这两个存储库,但这会更复杂,因为两个目录结构重叠。

Two solutions:

1/ you modify your index when working on your development branch in order to never consider the sensitive files modified

    git update-index --assume-unchanged my/sensitive/file

2/ You use a filter driver in order to generate the sensitive files from;

enter image description here

  • a template file (versioned)
  • a value file (not versioned)

See "How to keep different content of one file in my local and github repository?"


A third solution would be to isolate your dropin lib in a separate repo from your framework, and use the framework repo only to deploy on your disk a specific version, and then perform a checkout of your dropin lib repo directly within the copied framework.

You could also linked those two repos through submodules, but that is more complex as the two directory structures overlap.

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