git保持定制修改的开源软件是最新的工作流程? [英] git workflow for keeping custom-modified open source software up to date?

查看:140
本文介绍了git保持定制修改的开源软件是最新的工作流程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的大学为我们管理的服务器上的校园部门提供虚拟主机服务。安装开源第三方程序需要在程序运行之前修改程序中的文件权限和代码。 (如果您熟悉,我们使用suEXEC。)



我们目前通过安装程序脚本提供WordPress。用户上传最新的稳定版本,并通过SSH运行服务器端PHP脚本。此PHP脚本修改所有文件/文件夹的文件权限,在各种文件中添加/删除一些代码,并创建一些新文件。这个安装程序脚本在发布新稳定版本时是一项麻烦的平衡操作。



我想开始使用版本控制(特别是git)来跟踪我们的自定义更改,而不是依赖脚本进行更改,但我不确定工作流程使用。我熟悉分支和合并,但不知道如何在发布新版本时整合旧版本。

改变WordPress核心,但也保留我们旧的自定义更改?

解决方案

我会建议保留您的更改在一个分支,每当你更新时,将分支与WordPress的最新版本进行重新分配。在一个粗略的时间表...

  +  -  WordPress 1.0 
v
[master] - * - *
\
[custom] * - * - *< - 您的定制

当你想更新WordPress时,切换到master并使用最新的源提交一个新的提交(或者使用git-svn来保持master同步):

  +  -  WordPress 1.0 
| + - WordPress 1.1
vv
[master] - * - * - * - *
\
[custom] * - * - *< - 你的定制

现在你可以做一个 git rebase master custom 可以根据最新情况重播您的更改,解决沿途的任何冲突。您的时间线将如下所示:

  +  -  WordPress 1.0 
| + - WordPress 1.1
vv
[master] - * - * - * - *
\
[custom] * - * - *< - 您的定制

更新:提供一点理由...我喜欢这种方法解决这个问题,因为它提供了来自WordPress的代码和您的自定义之间的明显区别。当你得到一个新版本的WordPress时,你对整合真的不感兴趣。您有兴趣将自定义设置重新应用到新版本的WordPress。在我看来,这种recustomization是最容易做的承诺通过承诺通过rebase。任何冲突意味着一个定制可能会破坏,所以旧的定制提交是垃圾无论如何 - 更好地解决问题的源头,并保持更新的历史清洁。



After master 被更新并且 custom 被重新设定并被推送,合作者只会将他们的工作进程重新设置为最新版本。

这只是我的看法,作为一个坚定的重组>合并支持者。 Git的美妙之处在于很少有正确的答案。只要不断调整,直到找到适合您的东西。


Our University provides web hosting to campus departments on servers we manage. Installing open-source third-party programs requires modifying file permissions and code in the program before it will run. (We're using suEXEC, if you're familiar.)

We currently offer WordPress via an installer script. The user uploads the newest stable release, and runs a server-side PHP script via SSH. This PHP script modifies file permissions of all files/folders, adds/removes some code in various files, and creates a few new files. This installer script is a cumbersome balancing act when a new stable version is released.

I want to start using version control (specifically git) to track our custom changes instead of relying on a script to make the changes, but am unsure of the workflow to use. I'm familiar with branching and merging, but not sure how to integrate our old changes when a new release is issued.

What should my git workflow be to integrate the new changes from the WordPress core, but also preserve our older custom changes?

解决方案

I would suggest keeping your changes in a branch, and rebasing that branch against the latest from WordPress whenever you update. In a rough timeline...

              +-- WordPress 1.0
              v
[master] --*--*
               \
[custom]        *--*--*     <- your customizations

When you want to update WordPress, switch to master and make a new commit with the latest souce (or use git-svn to keep master in sync):

              +-- WordPress 1.0
              |     +-- WordPress 1.1
              v     v
[master] --*--*--*--* 
               \
[custom]        *--*--*     <- your customizations

Now you can do a git rebase master custom to replay your changes against the latest, resolving any conflicts along the way. Your timeline would then look like this:

              +-- WordPress 1.0
              |     +-- WordPress 1.1
              v     v
[master] --*--*--*--* 
                     \
[custom]              *--*--*     <- your customizations

Update: To provide a bit of rationale... I like this approach for this problem because it provides a clear differentiation between code from WordPress and your customizations. When you get a new version of WordPress, you're really not interested in "integration". You're interested in re-applying your customizations to the new version of WordPress. In my view, that recustomization is most easily done commit by commit through a rebase. Any conflicts mean a customization likely broke, so the old customization commit is garbage anyway - better to just fix the problem at its source and keep the updated history clean.

After master is updated and custom is rebased and pushed, the collaborators would just rebase their work-in-progress against the latest.

This is just my opinion, as a firm rebase > merge proponent. The beauty of Git is that there's rarely one right answer. Just keep adjusting until you find something that works for you.

这篇关于git保持定制修改的开源软件是最新的工作流程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆