Git分支以使子项目保持最新

时间:2021-08-07 20:08:45

I have a problem that's very hard to google, so I decided to ask about it here.

我有一个问题,谷歌很难,所以我决定在这里问一下。

I've created a system (a rails app) that handles user registration for a conference. The system is under active development.

我创建了一个处理会议用户注册的系统(rails应用程序)。该系统正在积极开发中。

Now, I'm helping to run another conference, and I want to use pretty much the same system, with only minor changes to the codebase. However, I want to maintain some level of parallelism between the two projects, so I can easily push generic improvements to both systems. I also want to be able to change both independently.

现在,我正在帮助运行另一个会议,我想使用几乎相同的系统,只需对代码库进行微小的更改。但是,我希望在两个项目之间保持一定程度的并行性,因此我可以轻松地将两个系统的通用改进推进。我也希望能够独立改变它们。

My gut feeling is that I should use a branch for each conference's system, and then whenever I have a master change, run git merge master in both projects.

我的直觉是我应该为每个会议的系统使用一个分支,然后每当我有一个主变更时,在两个项目中运行git merge master。

Is there a smoother way to do this? Does git have a built-in method for handling automatic pushes to branches?

有更顺畅的方法吗? git是否有内置的方法来处理自动推送到分支?

Thanks in advance. I apologize if this question isn't as "answerable" as * likes.

提前致谢。如果这个问题不像*那样“回答”,我很抱歉。

2 个解决方案

#1


2  

What you propose (3 branches) would certainly work, but if I were to do it, I'd probably make 3 git repositories rather than 3 branches.

你提出的建议(3个分支)肯定会有用,但如果我这样做,我可能会制作3个git存储库而不是3个分支。

There is no way for git to automatically merge the master branch (your shared library) into the two implementation branches. You would need to do that yourself.

git无法自动将主分支(您的共享库)合并到两个实现分支中。你需要自己做。

#2


2  

I would use two branches for now, but heavily prioritize fixing the code itself to support the modifications in a single codebase. Otherwise you'll experience more and more pain as the code changes and/or the variants diverge: bigger merges, more space for conflicts, harder refactoring, etc.

我现在会使用两个分支,但是重点优先考虑修复代码本身以支持单个代码库中的修改。否则,随着代码的变化和/或变体的分歧,你会遇到越来越多的痛苦:更大的合并,更多的冲突空间,更难的重构等等。

#1


2  

What you propose (3 branches) would certainly work, but if I were to do it, I'd probably make 3 git repositories rather than 3 branches.

你提出的建议(3个分支)肯定会有用,但如果我这样做,我可能会制作3个git存储库而不是3个分支。

There is no way for git to automatically merge the master branch (your shared library) into the two implementation branches. You would need to do that yourself.

git无法自动将主分支(您的共享库)合并到两个实现分支中。你需要自己做。

#2


2  

I would use two branches for now, but heavily prioritize fixing the code itself to support the modifications in a single codebase. Otherwise you'll experience more and more pain as the code changes and/or the variants diverge: bigger merges, more space for conflicts, harder refactoring, etc.

我现在会使用两个分支,但是重点优先考虑修复代码本身以支持单个代码库中的修改。否则,随着代码的变化和/或变体的分歧,你会遇到越来越多的痛苦:更大的合并,更多的冲突空间,更难的重构等等。