How to do branching approach for multiple sites?

泪湿孤枕 提交于 2019-12-04 17:20:47
VonC

It can work, provided your main single repo is a bare repo to which you can push.

From there, a post-receive hook can trigger the relevant checkout, depending on the branch which has been pushed (see "Writing a git post-receive hook to deal with a specific branch")

#!/bin/bash
while read oldrev newrev refname
do
    branch=$(git rev-parse --symbolic --abbrev-ref $refname)
    if [ "master" == "$branch" ]; then
        # Do something
    fi
    if [ "sandbox" == "$branch" ]; then
        # Do something
    fi
    if [ "development" == "$branch" ]; then
        # Do something
    fi
done

For changes, development will be pushed to both master and sandbox branch. Sandbox will never be pushed to master.

That is not the best practice: you should merge what you need from dev to the master and sandbox local branches, and then push those branches to the unique remote repo.
Regularly rebasing dev on top of master is also a good idea.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!