zoukankan      html  css  js  c++  java
  • Git bare repo with multiple branches

    http://stackoverflow.com/questions/9324762/git-bare-repo-with-multiple-branches

    Q:

    I want to make a git bare repository with multiple branches (master, develop, release, etc..).

    So question is if it is possible to checkout the bare repository or how to switch among the branches (does it make a sense to switch)?

    When I want to push to the bare repository can I make a merging on bare repository or merging must be done locally and push the adequate branch?So looking for a right approach :-)

    Thanks Peter

    A:

    I want to make a git bare repository with multiple branches (master, develop, release, etc..).

    Judging from the question, it seems that you are unsure of the reasons you would make a bare git repository, and how you would use said repository. The question is, why do you wish to make a bare repository?

    From Pro Git, a bare repository is "a repository that doesn’t contain a working directory." It's a repository that you don't work out of, and is just used to git push and git pull from. The reason for this is summed up here:

    "A bare repository is one without a checked out working copy of the code. It only contains the git database. As a general rule you should never push into a repository that contains changes in the working copy. To ensure this doesn't happen, we're making the server repository a bare repository - it has no working copy."

    So, a bare git repository can definitely contain multiple branches. You can definitely fetch a copy of the bare remote repository into your local repository, and push from your local repository to your remote (bare) repository. However, you don't want to work out of your bare repository. (Furthermore, it is impossible to run git add whilst in a bare repository; see this SO question for clarification).

    So question is if it is possible to checkout the bare repository or how to switch among the branches (does it make a sense to switch)?

    This question, I think, is not entirely clear, because you never really switch branches on the bare repository - you never work on the bare repository. All you do is push or pull from it.

    When I want to push to the bare repository can I make a merging on bare repository or merging must be done locally and push the adequate branch? So looking for a right approach :-)

    To git-push to a bare repository, you must first ensure that there is no merge conflict - if there is, the push will fail (Reference: book.git-scm.com, "Pushing changes to a public repository"). Merging must therefore be done locally, and then changes fast-forwarded on the bare repository with git-push.

    So looking for a right approach.

    There isn't anything special about a bare repository, aside from the fact that you should not and can not work out of it. As others have referenced, the gitflow model gives you an idea of a workflow involving several repositories - there are lots of questions on SO asking for git workflow examples and methodologies. Almost every reference (1, Pro Git), (2, book.git-scm.com) uses a bare repository in conjunction with a public or published repository - the linked articles discuss creation and use of bare repositories in detail. 

  • 相关阅读:
    ThinkPHP5远程代码执行高危漏洞(附:升级修复解决方法)
    PowerDesigner 表格导出为excel
    ubuntu 18.04 配置远程ssh/远程ftp/远程vnc登陆
    Linux apache的运行用户和用户组
    mac系统 安装pip,用python读写excel(xlrd、xlwt)安装
    nvm 设置 nodejs 默认版本
    js基础
    Node.js 8 中的 util.promisify的详解
    HTTP协议中POST、GET、HEAD、PUT等请求方法以及一些常见错误
    MQTT简介
  • 原文地址:https://www.cnblogs.com/baiyw/p/3317801.html
Copyright © 2011-2022 走看看