GIT:针对这种情况的最佳工作流程是什么?
我遇到了这种情况的问题:
我有一个包含“docs”、“layout”、“pub”和“sql”文件夹的基本存储库,“docs”中只有一个空白的“index.html”, “布局”文件夹。在“pub”文件夹中我安装了 Joomla。
当我有一个新客户端时,我创建他的目录并初始化一个存储库,然后添加一个名为“base”的远程存储库,指向基本裸存储库(带有 Joomla 的存储库),获取它,签出 base/master,然后执行“签出 - b master' 从基础的 master 分支创建 master 分支。然后,我在本地服务器中对客户端的存储库进行“克隆-裸”,并在本地工作站中从中进行克隆。我们在需要时保存文档,设计师制作布局,然后将其提交并推送到客户的裸存储库。我们总是在推送之前执行“rebase origin/master”,以确保本地存储库是最新的。
因此,当布局完成并推送后,我将其拉出并开始制作 Joomla 模板。所以我做了很多提交,然后我意识到我必须在 Joomla 组件中进行更改。好的,我更改组件,提交并继续制作模板,提交,...
现在我想将所有 Joomla 组件的提交带到“基本存储库”,因为我希望所有客户都有相同的更改。当我尝试 @jleedev 解决方案(变基)时,我客户的所有提交都转到顶部,重写了客户裸存储库中已经存在的 SHA。
基本想法是在“docs”、“layout”、“pub/templates/client_template”文件夹中提交文件,也许还有一些 Joomla hack 只是针对该客户端,该客户端是该客户端的存储库所独有的,但我想要的所有其他提交也包含在“基础”Joomla 存储库中,这样我就可以合并到所有客户端存储库中。
有什么想法吗?也许是不同的组织?
提前致谢!
I'm having problems with this situation:
I have a base repository that contains a 'docs', 'layout', 'pub' and 'sql' folder, there is just a blank 'index.html' in the 'docs' and 'layout' folder. In the 'pub' folder I have Joomla installed.
When I have a new client I make his directory and init a repository, then I add a remote named 'base' pointing to the base bare repository (the one with Joomla), fetch it, checkout base/master and then do 'checkout -b master' to create the master branch from the base's master branch. Then I make a 'clone --bare' of the client's repo in my local server and clone from it in local workstations. We save docs when needed, the designer makes the layout then it's commited and pushed to the client's bare repo. We always do a 'rebase origin/master' before pushing, to make sure the local repo is up to date.
So when the layout is done and pushed, I pull it and start to make the Joomla template. So I make lots of commits, then I realise that I have to make changes in a Joomla component. Ok, I change the component, commit and continue making the template, commit, ...
Now I want to bring all the Joomla component's commits to the 'base repo' because I want all my clients to have the same changes. When I tried @jleedev solution (rebasing), all my client's commits went to the top, rewriting it's SHA's that were already in the client's bare repo.
The basic idea is to have the commits of files in the 'docs', 'layout', 'pub/templates/client_template' folder and maybe some Joomla hack just for that client unique to the client's repo, but all other commits I would like to have in the 'base' Joomla repo too so I can merge into all clients repos.
Any ideas? Maybe a different organization?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
所以你有两个用于两个不同目的的文件集。
我会将这两个部分分开(即一个不包含在另一个中),并将 Joomla 组件部分作为 子模块。
其他目录将保持特定于客户端。
So you have two set of files for two different purpose.
I would keep those two separate (i.e. one not being included in the other), with the Joomla component part as a submodule.
The other directories would remain client-specific.
也许您可以直接在您的 Joomla 基础存储库中进行您希望所有客户都能进行的更改。然后将其合并到所有客户端存储库中。
编辑:这需要您在 Joomla 组件中的每次更改之前决定是否希望该更改可供所有客户端使用,或者是否只是客户端特定的更改。也许这并不总是那么容易做到。
Maybe you could do the changes you want all clients to have directly in your Joomla base repo. And then merge that into all client repos.
Edit: This would require you to decide before every change in the Joomla components if you want the change to be available to all clients or if it's just a client specific change. Maybe that isn't always easy to do.
我认为这个问题超出了git的范围。
我想说的是,你应该始终保持所有项目的“共同基础”。
如果一个项目需要特定的 hack,您应该尝试进行,以免影响其他存储库。例如,默认将其关闭,并且仅针对特定网站打开。
强迫自己这样做的一种方法是让他们都使用完全相同的“通用”存储库;不是它的克隆。例如,您可以将符号链接用于基本/公共代码库。
I think this problem is outside the scope of git.
I'd say you should always keep the 'common base' common for all projects.
If one project requires a specific hack, you should try and make so that it doesn't affect other repos. For example, make it off by default, and only on for that certain website.
One way to force yourself to do that is have them all use the exact same "common" repo; not a clone of it. You can use symlinks for the base/common code base, for instance.
要将现在的内容放入 base/master 中,您可以尝试以下操作:在客户端存储库中,在 base/master 处创建一个“base”分支。
(git checkout -b 基础基础/主)。然后挑选您想要推回基地的 joomla 提交。然后将底座推送到底座/主控。
不过,如果您尝试将 master 重新设置为新的 base/master,则可能会遇到棘手的重新设置,因为您精心挑选的提交将采用不同的顺序。不知道该怎么办。
在同一个存储库中保留两棵独立的树有一些技巧;也许这就是你应该使用的。阅读 http://progit.org/book/ch6-7.html 并查看如果这个想法适合你的情况,你想保留一个稍微修改过的 Joomla 和各种其他存储库。
To get what you have now into base/master, you could try this: In a client repo, create a "base" branch at base/master.
(git checkout -b base base/master). Then cherry-pick the joomla commits you want to push back into the base. Then push base to base/master.
You might end up with a tricky rebase if you try to rebase master onto the new base/master, though, since the commits you cherry-picked will be in a different order. Not sure what to do about that.
There are tricks for keeping two separate trees in the same repo; maybe this is what you should use. Read http://progit.org/book/ch6-7.html and see if that idea could work for your situation, where you want to keep a slightly modified Joomla and various other repos.
这个问题看起来几乎像是一个继承问题(相对于您的组织)。
与 hasen j 所说的类似,您需要一个包含所有共同点的基础,然后从那里进行分支 - 如果您的某些客户网站有特定的结构,而其他网站则没有,您将使用一个子库 git 存储库来表示该特定子集中的通用功能。
这样,如果您想对所有存储库进行更改,请通过基本存储库进行更改。如果要更改特定子集,请更改为该子集创建的子基础存储库。
This question seems almost like an inheritance problem (with respect to your organisation).
Similar to what hasen j said, you need a base that contains everything that's in common, and then branch out from there - if you have a specific structure for some of your client's websites that is not in others, you'll use a sub-base git repository to represent the common functions among that specific subset.
That way, if you want to make a change to all repositories, make it through the base repository. If you want to change a specific subset, change the sub-base repository created for that subset.