git合并分支在裸仓库中 [英] git merging branches in a bare repository

查看:154
本文介绍了git合并分支在裸仓库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的git仓库创建以下设置:



我目前有一个本地git仓库,包含我所有的工作文件。我希望能够设置一个中央裸仓库和另外两个非裸仓库 - 一个用于实时应用程序,另一个用于测试版本。



我希望能够在测试分支上将本地变更推向中央裸回购。然后,在我的测试回购中,总是从裸仓库的测试分支中取出。

准备好接受更改时,我希望能够将测试分支和主分支合并到中央裸仓库中。然后,实时回购可以从主分支拉。



所以在这个方案中,测试回购将总是从测试分支拉出来,而实时回购总是会从主分支拉出来。

我无法弄清楚如何在裸仓库中合并分支。



所以,我的问题是双重的:


  1. 有没有一种标准的方法来合并裸露回购中的分支?

  2. 这是不是直截了当,因为我的回购设置很穷? (在这种情况下,如何修改此架构以获得最佳做法?)
  3. code> git checkout 检查一个分支进入工作树 - 你认为这应该在没有工作树的情况下工作吗?并且 git merge 和大多数其他命令不起作用,因为裸仓库中没有HEAD。



    回答你的问题:你不在裸仓库中工作。裸仓库仅用于保存数据;如果您想使用它,请使用一个不是空白的克隆。

    因此,从任何其他存储库中,您从裸存储库中取出,在本地合并并推送您的更改回到它。你应该从你的开发资源库中做到这一点。因此实时和测试版本库仅从其分支中提取。


    I would like to create the following setup for my git repos:

    I currently have a local git repo with all my working files. I would like to be able to setup a central bare repository, and two other non-bare repositories -- one for a live application and one for a testing version.

    I would like to be able to push changes from local to the central bare repo on a testing branch. Then, on my testing repo, always pull from the testing branch of the bare repository.

    When ready to go live with the changes, I would like to be able to merge my testing branch and my master branch in the central bare repository. Then the live repo could pull from the master branch.

    So in this scheme, testing repo will always pull from testing branch, and live repo will always pull from the master branch.

    I can't figure out how to merge branches in a bare repository though. git-merge and git-checkout don't seem to work without the working tree.

    So, my question is two-fold:

    1. Is there a standard way to merge branches in a bare repo?
    2. Is this not straight-forward because the setup of my repos is poor? (In which case, how would you modify this architecture for best practices?)

    解决方案

    git checkout checks out a branch into the working tree – how do you think this should have worked without a working tree? And git merge and most other commands don’t work, because there is no HEAD inside of a bare repository.

    To answer your question: You don’t work within the bare repository. A bare repository is only there to keep the data; if you want to work with it, use a clone which is not bare.

    So from any other repository, you pull from the bare repository, merge locally and push your changes back to it. You should do this from your development repository btw. so that the live and test repositories only pull from their branch.

    这篇关于git合并分支在裸仓库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆