从 Git 提交两个远程项目

发布于 2024-09-27 22:23:27 字数 401 浏览 2 评论 0原文

我在 Codeigniter 中有一个项目,通过 Git 和 Github 进行管理,其中包含我用于所有 CI 项目的“样板”自定义和库(如集中式渲染库)——我们称之为“基线”。

在我开发和完善 Baseline CI 项目的同时,我也在开发当前的客户端项目,我们将其称为“客户端”。

我的问题是 - 同时开发基线项目和客户项目的最有效方法是什么?例如,我可以在客户端项目中创建一个新的控制器和模型,然后添加新的帮助器、一些通用视图,并添加到我认为需要添加到基线中的几个库。我是否需要执行两次提交,一次提交给基线(并将其推送到远程基线存储库),然后再次提交给客户端项目?

我一直在试图弄清楚如何使用子模块或分支来完成同样的事情,但子模块似乎需要在 Git 中拥有自己的目录结构,并且对于分支,我不确定它是如何工作的。

帮助?

I have a project in Codeigniter, managed via Git and Github, that consists of my 'boilerplate' customizations and libraries (like a centralized Render library) that I use for all of my CI projects - let's call that 'Baseline'.

At the same time that I'm developing and refining the Baseline CI project, I'm also developing the current client project, which we'll call 'Client'.

My question is - what's the most efficient way to develop both the Baseline project and the client project simultaneously? For example, I may create a new controller and model in the Client project, but then add new helpers, some generic views and add to a couple of the libraries that I think need to be added to Baseline. Do I need to perform two commits, one for the Baseline (and push that to the remote Baseline repo), then commit again for the Client project?

I've been trying to figure out how to use submodules or branching to accomplish the same thing, but submodules seem to require their own directory structure in Git, and with branching I'm not sure how it would work.

Help?

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

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

发布评论

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

评论(2

柳若烟 2024-10-04 22:23:27

因为我猜测子模块所需的单独目录结构设置不适合您,所以我建议如下:

  1. 拥有一个存储库 (A),它是您的“基准”项目。在该存储库中的基线上完成所有工作,然后将其提交到那里。

  2. 将该存储库克隆到另一个存储库 (B),并在那里完成客户端项目的所有工作。将 (A) 保留为远程(如果您 git clone (A),它将自动设置为 origin;您可以将 github 远程添加为 github 而不是 origin)。

  3. 然后,当您对基线 (A) 存储库进行更新时,将它们提交到 (A),然后使用 git pull 将它们从 (A) 拉取到 (B)。 (切勿从 (B) 推送到 (A),因为您不希望基线存储库中包含客户端代码。)

所以,是的,您需要分别提交基线更新和客户端更新,但您不必这样做提交相同的代码两次。

Since I'm guessing the separate-directory-structures setup that submodules require is no-go for you, here's what I'd suggest instead:

  1. Have one repository (A) that is your "baseline" project. Do all of your work on the baseline in that repository, and commit it there.

  2. Clone that repository to another, (B), and do all of your work for the client project there. Keep (A) as a remote (if you git clone (A), it'll be set as origin automatically; you could add the github remote as github instead of origin).

  3. Then, when you make updates to the baseline (A) repository, commit them to (A), and then use git pull to pull them from (A) to (B). (Never push from (B) to (A), since you don't want client code in the baseline repo.)

So yes, you will need to commit your baseline updates and your client updates separately, but you won't have to commit the same code twice.

べ映画 2024-10-04 22:23:27

我建议使用分支或子模块。

对于分支,您将拥有一个 baseline 分支和一个 client 分支。每当您在更新 baseline 后切换到 client 时,请将 baseline 合并到 client 中。

对于子模块,任一存储库都可以是顶级模块,而另一个存储库可以是其子模块。两种布局都有一定的逻辑意义(baseline 位于顶部,client 依赖于它,因此是一个子布局;而 client 位于顶部,它使用baseline 作为一个库,所以这应该是孩子,由你决定)。

不过,我会推荐分支。

I would recommend using branches or submodules.

With branches, you would have a baseline branch and a client branch. Whenever you switch to client after updating baseline, merge baseline into client.

With submodules, either repository could be the top-level module, with the other as its child. Both layouts make some logical sense (with baseline on top, client depends on it and is therefore a child; with client on top, it uses baseline as a library, so that should be the child; it's up to you).

I would recommend the branching, though.

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