How to do branching approach for multiple sites?

試著忘記壹切 提交于 2019-12-09 22:58:49

问题


I'm new to git and would want to know if this branching approach would be okay for what we intended to do.

We'll have three sites

  • prod.websitename.com - live site
  • sandbox.websitename.com - testing site that can be used by our clients
  • dev.websitename.com - internal site for developing and testing hotfix/features before pushing to live site

What we intend to do is to have a single centralized repository that would serve all three sites. The repository will have three branches: master, sandbox, and development

and then we'll just checkout the branch to change files and pull/push the changes for each site.

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

Is this okay? Any advice is highly appreciated.

Thank you so much.


回答1:


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.



来源:https://stackoverflow.com/questions/16056561/how-to-do-branching-approach-for-multiple-sites

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