tl; dr:在git push我想达到以下目的:
local/staging -> wpengine-staging/master local/staging -> gitlab/staging local/master -> wpengine-production/master local/master -> gitlab/master详细信息:我正在https://wpengine.co.uk/上开发一个站点,使用他们的分段和生产环境以及他们的git推送功能。
Wpengine在git repo / branch production/master上进行production/master并在repo / branch staging/master上进行staging/master 。
为了让我分别从一个本地wpengine-production分支/主分支,我设置了两个远程: wpengine-production和wpengine-staging 。
然后我设置上游为我的本地staging到wpengine-staging master我的本地master到wpengine-production master以及git config push.default upstream
到目前为止这么好 - 现在,当我从任一分支git push它将我的提交发送到所需的远程和分支。
接下来,我需要在gitlab仓库上保留一份代码。
为此,我的本地回购应该推送到gitlab/staging和master到gitlab/master 。
现在,我意识到Git - 将代码推送到两个远程,并且对于主分支应该工作得很好。
然而,我正在努力为staging分支设置,因为如果我在一个远程单元上使用了两个push url,我需要为每个URL /分支在同一分支上设置两个不同的上游。
据我所知,这是不可能的。
所以安装明智我可以有:
两个带两个推送网址的遥控器,我们称它们为production和staging :
production -> gitlab & wpengine-production
staging -> gitlab & wpengine-staging
或者,我可以有三个遥控器,每个网址一个:
gitlab , wpengine-staging , wpengine-production 。
我知道我可以设置一个别名来推送到两个远程分支机构,如果只是我,那很好,但是由于其他人会在项目上工作,我真的希望尽可能地做到这一点,并在git push上启用此行为。
作为一个侧面说明 - 关于git pull我需要它从wp-engine遥控器中取出,但是这一部分我没有问题(我认为)。
最后,我很清楚,我试图实现的目标可能是不可能的,并且出于很好的理由(在这种复杂设置的推/拉上应该明确说明遥控器)。 我正在探索这个的唯一原因是为了避免人为错误。
tl;dr: On git push I would like to achieve the following:
local/staging -> wpengine-staging/master local/staging -> gitlab/staging local/master -> wpengine-production/master local/master -> gitlab/masterDetails: I am developing a site on https://wpengine.co.uk/ using their staging and production environments as well as their git push feature.
Wpengine has production on a git repo/branch production/master and staging on a repo/branch staging/master.
To allow me to push to these respectively from one local repo with staging/master branches I have set up two remotes: wpengine-production and wpengine-staging.
I then set the upstream for my local staging to wpengine-staging master and for my local master to wpengine-production master as well as git config push.default upstream
So far so good - now when I git push from either branch it sends my commits to the desired remote and branch.
Next I need to keep a copy of the code on a gitlab repo.
For this my local repo should should push staging to gitlab/staging and master to gitlab/master.
Now, I am aware of Git - Pushing code to two remotes and that should work just fine for the master branch.
I am however, struggling with the setup for the staging branch since, if I used two push URLs on a single remote, I would need to set two different upstreams on the same branch for each URL/branch.
As far as I can tell this isn't possible.
So setup wise I could have either:
Two remotes with two push URLs each, let's call them production and staging:
production -> gitlab & wpengine-production
staging -> gitlab & wpengine-staging
Or, I could have three remotes, one for each URL:
gitlab, wpengine-staging, wpengine-production.
I know I could set an alias to push to two remote branches and that would be fine if it was just me but since others will be working on the project I really want to make this as fool proof as possible and enable this behaviour on git push.
As a side note - on git pull I need it to take from the wp-engine remotes but that part I don't have an issue with (I think).
Finally, I am well aware that what I am trying to achieve probably isn't possible, and for good reasons (remotes should be explicitly stated on push / pull on complex setups like this). The only reason I am exploring this is to avoid human error when working with this down the line.
最满意答案
我认为这是你需要的:
Git - 将代码推送到两个遥控器
所以基本上你可以为同一个遥控器设置multile push url,一个用于gitlab,另一个用于另一个,保持所有遥控器同步。
或者你可以创建服务器端的钩子,所以例如gitlab将推到另一个。
I think this is what you need:
Git - Pushing code to two remotes
So basically you set up multile push url for the same remote, one for gitlab, one for the other, keeping all remotes synced.
Or you can create server side hooks, so for example gitlab will push to the other one.
更多推荐
发布评论