简体   繁体   English

将分支推送到其他遥控器

[英]Push Branch to Different Remote

This is my current workflow for a web development environment: In the server I have a post-receive hook for every repo, so when someone push something, it sets the working tree to the Apache document root, and checkouts the changes, something like this: 这是我当前用于Web开发环境的工作流程:在服务器中,每个存储库都有一个接收后挂钩,因此当有人推送内容时,它将工作树设置为Apache文档的根目录,并签出更改,类似这样:

#!/bin/sh
GIT_WORK_TREE=/var/www/project git checkout -f

It've been working pretty fine since then. 从那时起,它一直运行良好。 But now in my team we've decided to begin using branches to work with our issues (something like a topic-based workflow), so our idea is to create a development branch, and then create a branch for every issue, based on the dev branch. 但是现在,在我的团队中,我们已经决定开始使用分支来处理我们的问题(类似于基于主题的工作流),因此我们的想法是创建一个开发分支,然后针对每个问题创建一个分支。开发分支。 Then when someone finish their work, they merged with the dev branch, then QA check it outs, and then merge back to master (the production branch). 然后,当某人完成工作时,他们与dev分支合并,然后由QA检出,然后合并回master(生产分支)。

Currently all the changes to the repo are pushed to the master branch on the server and then they can be viewed on the website, but when I make a new branch and push the changes, the working tree isn't updated (maybe something with the hook). 当前,对仓库的所有更改都被推送到服务器上的master分支,然后可以在网站上查看它们,但是当我创建一个新分支并推送更改时,工作树不会被更新(可能与钩)。

My idea is to have a different remote for the development branch and a different remote for the production (master) branch, and be able to checkout the changes as I've been doing till now and view them online. 我的想法是为开发部门使用一个不同的遥控器,为生产(主)分支使用一个不同的遥控器,并且能够像现在一样签出更改并在线查看它们。 Is this posible? 这可能吗? Do I've to create a different repo for the dev branch? 我是否需要为dev分支创建其他仓库?

What you describe is implemented in gitFlow 您描述的内容在gitFlow中实现

https://github.com/nvie/gitflow https://github.com/nvie/gitflow

http://nvie.com/posts/a-successful-git-branching-model/ http://nvie.com/posts/a-successful-git-branching-model/

if you still decide to use different remotes i suggest that you will have different branches per remote and then sync them whenever you need to. 如果您仍然决定使用其他遥控器,我建议您为每个遥控器设置不同的分支,然后在需要时进行同步。

Having more than one remote is really no problem. 拥有多个遥控器确实没有问题。

git remote add devel /path/to/remote1
git remote add production /path/to/remote2

Push a devel branch to devel : 推动devel分支进行devel

git push devel devel_branchname

Push something to the master branch: 将某些内容推送到master分支:

git push production master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM