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.

最新文章

  1. Sql Server函数全解(二)数学函数
  2. 嵌入式Linux驱动学习之路(十七)驱动程序分层分离概念-平台设备驱动
  3. 在.NET中使用JQuery 选择器精确提取网页内容
  4. 如何结合自己本地数据库,使用【百度地图】API
  5. clang: error: no such file or directory: xxx.pch
  6. POJ C++程序设计 编程题#1 编程作业—运算符重载
  7. instanceof、==号、Objetc类
  8. 背景透明文字不透明的最佳方法兼容IE(以背景黑色透明度0.5为例)
  9. bzoj 2829 信用卡凸包(凸包)
  10. QTableView 添加进度条 添加按钮 TreeWidget 增删改
  11. 寒假学干货之------LinearLayout.layout.weight
  12. hdu-1978_How many ways dfs+记忆化搜索
  13. Window7 下 WNMP 环境搭建
  14. Java中的volatile变量有什么作用?
  15. 自学Python之路-Python并发编程+数据库+前端
  16. excel单元格内换行的方法
  17. 小白之selenium+python关于cookies绕开登录1
  18. navicat premium 的使用——navicat 连接MySQL数据库
  19. maven工程pom.xml报Missing artifact net.sf.jasperreports:jasperreports:jar:6.2.0
  20. ORACLE 10g RAC [ CSSCLNT][1]clsssInitNative: connect failed, rc 9

热门文章

  1. eclipse中添加svn插件
  2. ESXi 给虚拟机添加网络串口
  3. bzoj 4034 [HAOI2015]树上操作 入栈出栈序+线段树 / 树剖 维护到根距离和
  4. 【CF1027B】Numbers on the Chessboard(数学)
  5. 【BZOJ1901】Dynamic Rankings(树套树,树状数组,主席树)
  6. (转):从内核代码聊聊pipe的实现
  7. Lua开发环境搭建(Mac OS X)
  8. Spring MVC学习一
  9. 详解DNS域名解析全过程
  10. 最小生成树-prim算法模板