arielcr
arielcr

Reputation: 1663

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:

#!/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).

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).

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?

Upvotes: 0

Views: 154

Answers (2)

eckes
eckes

Reputation: 67037

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:

git push devel devel_branchname

Push something to the master branch:

git push production master

Upvotes: 0

CodeWizard
CodeWizard

Reputation: 141946

What you describe is implemented in gitFlow

https://github.com/nvie/gitflow

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.

Upvotes: 1

Related Questions