Git、SVN 等是否执行这种类型的“分支和分支”?合并”或者类似的东西?

发布于 2024-10-02 10:52:34 字数 540 浏览 2 评论 0原文

客户端具有基于相同代码的不同版本,基本上他们复制模板代码库,然后编辑该副本,然后在生产中使用该副本作为代码的实例。这意味着有 20 个版本的代码库正在运行,但 80% 的代码是相同的。在不改变工作流程的情况下,如果每个构建/分支的 VCS 中的代码发生更改,有一种方法可以合并源代码,然后构建代码。如果重要的话,代码是用 Perl 编写的。

如果是这样,这叫什么,VCS 是否管理“构建”(它是 Perl,实际上只是代码的版本)。

视觉: A、B、C自定义代码分支; X是共享代码

   |
   |
   X
   |
  /|\
 / | \
A  B  C
 \ | /
  \|/
   |
   |
   X
   |
   |
   |\
   | \
 A,B  C
   | /
   |/
   |
   |
   X
   |
   |      
  /|
 / |
A  B,C
 \ |
  \|
   |
   |
  Etc... Where X = 80% of the code.
   |
   |      

Client has different versions of the same code based, basically they copy a template code base, then edit the copy, and then use that copy in production as an instance of the code. Meaning there's 20 versions of the code base running, but 80% of the code is the same. Without changing their workflow is there a way to merge the source code and then do builds of the code if the code changes in the VCS for each of the builds/branches. Code is in Perl if that matters.

If so, what is this called, and does the VCS manage the "builds" (it's Perl, really just versions of the code).

Visual: A,B,C custom code branches; X is shared code

   |
   |
   X
   |
  /|\
 / | \
A  B  C
 \ | /
  \|/
   |
   |
   X
   |
   |
   |\
   | \
 A,B  C
   | /
   |/
   |
   |
   X
   |
   |      
  /|
 / |
A  B,C
 \ |
  \|
   |
   |
  Etc... Where X = 80% of the code.
   |
   |      

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

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

发布评论

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

评论(3

您的好友蓝忘机已上羡 2024-10-09 10:52:34

是的,你可以,但在我解释之前,我必须强烈建议你不要这样做。最好将变量内容与共享内容分开,并将共享内容转换为某种框架,这可能就像将变量内容移动到“sites”目录中一样简单(我猜你正在构建罐装的网站),框架在运行时选择 20 个子目录(添加到模块路径)(use lib "sites/$site"; 可能会成功,但不要引用我的话)。

如果您确实必须通过版本控制来管理此问题,您可以简单地为每个站点创建一个分支,在 master 上维护核心代码库,并定期从 master 合并到每个站点以传播更新。如果变量和共享代码完全分离,则很少需要人工干预。

Yes you can, but before I explain it, I have to strongly recommend that you not do this. It is much better to separate the variable stuff from the shared stuff, and turn the shared stuff into some kind of framework, which could be as simple as moving the variable stuff into a "sites" directory (I'm guessing you are building canned web sites) with 20 subdirectories that the framework chooses from (adds to the module path) at runtime (use lib "sites/$site"; might do the trick, but don't quote me on that).

If you really, really have to manage this via version control, you can simply create a branch for each site, maintain the core code base on master, and regularly merge from master to each site in order to propagate updates. If the variable and shared code are cleanly separated, this will rarely require human intervention.

把昨日还给我 2024-10-09 10:52:34

我想这可以通过分支来完成,但我认为拥有一个更智能的模板系统来知道如何加载模板的正确版本会更理想。如果您坚持使用分支,您可以通过拥有一个包含所有公共代码的主分支(用 Git 的说法)和每个变体的分支来实现。对特定版本的更改可以在相关分支上完成,而影响所有内容的更改可以在主分支上完成。但是,您必须将最新的主更改单独合并到每个分支中,除非您为其编写了某种自动化操作。再说一次,我不认为使用分支来做这样的事情是最好的主意,但你也许能够让它发挥作用。

I suppose this could be done with branches, but I think it'd be more ideal to just have a smarter templating system that knew how to load the correct version of the template. If you insist on using branches, you could do it by having a master branch (in Git parlance) that has all the common code, and a branch for each variation. Changes to a specific version could be done on the relevant branch, while changes that should effect everything could be done on the master branch. You'd have to merge the latest master changes into each branch individually, however, unless you wrote some sort of automation for it. Again, I don't think using branches for something like this is the best idea, but you might be able to make it work.

梦过后 2024-10-09 10:52:34

在 Git 中,您可以拥有 Git 存储库的多个完整克隆,其中每个克隆都是其自己的完整存储库。

  • 创建一个名为 client/custom 的新分支
  • 进行客户端更改并将其提交到 client/custom
  • 在“origin”存储库中进行更改。
  • 提交原始存储库中的更改。
  • 将更改从 origin/master 拉入 client/master
  • 将 client/custom 重新设置为最新的 client/master 或者 将最新更改从 client/master 合并到 client/custom。

这可能不是在 Git 中执行此操作的最快方法,但它可以工作(当然,假设您手动解决任何不稳定的合并。)

请参阅 http://git-scm.com/docs/git-rebase

In Git, you can have multiple complete clones of a Git repository, where each one is its own full repo.

  • Make a new branch called client/custom
  • Make client changes and commit them to client/custom
  • Make the changes in the "origin" repo.
  • Commit the changes in the origin repo.
  • Pull the changes from origin/master into client/master
  • Rebase client/custom to the latest client/master OR merge the latest changes from client/master into client/custom.

This may not be the quickest way to do it in Git, but it can work (assuming you manually resolve any wonky merges, of course.)

See http://git-scm.com/docs/git-rebase

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