单一的Git回购目录在多个位置 [英] Single Git repo with directories in multiple locations

查看:78
本文介绍了单一的Git回购目录在多个位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Git newb问题在这里。来自SVN,我可以有多个分支签出所有的地方(/ www / project1,/ users / project2等),但都住在同一个存储库中。每个分支都有它自己的提交,修订等等。你们知道这笔交易。



在Git中有类似的方法吗?你可以在这里有目录/分支一个回购遍布全地?再次,对于新问题感到抱歉。试图找到一个小珠子。通常,由于检出和合并过程非常快,因此开发人员可以使用这些功能来解决这个问题。

Git保留所有分支,并在相同的文件夹中切换它们。 SVN分支系统非常慢,并且不是很好,这就是为什么他们通常将它们保存在不同的文件夹中。



可以将分支结帐到不同的文件夹:

  git --work-tree =<目标路径> --git-dir =<来自源的路径>结帐< reference-name> 
#例如:
git --work-tree =。 --git-dir =/ base-repo / .gitcheckout master

这个新文件夹将不会被版本化。为了保持版本化,您可以在其他文件夹中重新克隆回购:

  git克隆路径/ to / local / repo / .git 

请注意,在git中,每个克隆都是完整的回购(完全相同你的服务器和你的其他文件夹)。每个克隆都是完全独立的,并且可以从任何其他回购中推/拉。



希望这有助于您!


Git newb question here. Coming from SVN, where I can have multiple branches checked out all of the place ("/www/project1", "/users/project2", etc.) but all live in the same repository. Each branch has it's own commits, revisions, etc. You guys know the deal.

Is there a similar method to this in Git, where you can have directories/branches in a single repo spread out all over place? Again, sorry for the newb question. Trying to get a bead on this. Thanks a bunch for any insight that can be provided here.

解决方案

Normally, as checkout and merging process are really fast, developers using Git keep all branches and just switch between them in the same folder. The SVN branching system is very slow, and not really good, that's why they usually kept them in a different folder.

It is possible to checkout a branch to a different folder:

git --work-tree=<path to target> --git-dir="<path from source>" checkout <reference-name>
# example:
git --work-tree=. --git-dir="/base-repo/.git" checkout master

Note, though, that this new folder won't be versioned. To keep it versioned, you could re-clone the repo in another folder:

git clone path/to/local/repo/.git

Note that in git, each clone is the full repo (the exact same thing there is on your server and in your other folder). Each clone is completely independent and can push/pull from any other repo.

Hope this helps!

这篇关于单一的Git回购目录在多个位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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