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. 

  • 相关阅读:
    yii修改密码 弹出修改成功提示(八)
    yii模型规则的简单使用以及开启前端的验证(七)
    利用ab测试并发可靠么
    yii数据库链接(六)
    初始化collectionViewCell
    监听事件
    ControllerEvent
    代码构建视图
    DeveloperAppleHelp
    Xcode 小技巧
  • 原文地址:https://www.cnblogs.com/baiyw/p/3317801.html
Copyright © 2011-2022 走看看