[英]How to properly initialize git-svn clone of a repository with nonstandard layout?
I am trying to work using git with svn repository that has the following rough layout: 我正在尝试将git与具有以下粗略布局的svn存储库一起使用:
RepositoryHone RepositoryHone
- -> Documents ->文件
- -> ExtraDocuments -> ExtraDocuments
- -> playground ->游乐场
- -> playground_dev ->操场_dev
- -> playground_balance_change ->操场平衡_变化
- -> Tools ->工具
where playground contains main development branch (trunk), and playground_dev, playground_balance_change and others not shown are branches. 游乐场包含主要开发分支(trunk),而游乐场_dev,游乐场_balance_change和其他未显示的是分支。
In branches, layout goes like this: 在分支中,布局如下所示:
- -> build ->建立
- -> lib ->库
- -> bin ->箱
- -> src -> src
I mostly wanted to work with playground and playground_dev, so i have run: 我主要想使用Playground和Playground_dev,所以我已经运行:
git svn init svn::/server.address:port/RepositoryHome -T playground -b playground_dev git svn初始化svn :: / server.address:port / RepositoryHome -T操场-b操场_dev
git svn fetch git svn获取
However, when i have run git branch -r
to check how branches were imported, i found with my growing horror, that there were, besides "origin/trunk", "branches" like "origin/bin", "origin/lib", " origin/src" and so on. 但是,当我运行git branch -r
检查分支的导入方式时,我感到越来越恐惧,除了“起源/树干”之外,还有“分支”,例如“起源/ bin”,“起源/ lib” ,“ origin / src”等。
How can i ensure correct mapping of branches between local working copy/git repository and the server? 如何确保本地工作副本/ git存储库与服务器之间的分支正确映射?
Is it possible to fix the situation without fully fetching, as process takes a lot of time (roughly 16 hours)? 由于过程需要很多时间(大约16个小时),是否可以在不完全获取的情况下解决问题?
For git svn
option -b
doesn't mean "this is a branch", it means "this is a directory where all subdirectories are branches" so git svn init -b playground_dev
takes subdirectories of playground_dev
as branches. 对于git svn
选项-b
并不意味着“这是一个分支”,这意味着“这是一个目录,所有子目录分支”如此git svn init -b playground_dev
需要的子目录playground_dev
为分行。
I don't see any simple way to overcome that. 我看不出有什么简单的方法可以克服这个问题。 I'd recommend to clone two times into separate repositories and combine these repos. 我建议将两次克隆到单独的存储库中并合并这些存储库。 Something like: 就像是:
git svn clone svn::/server.address:port/RepositoryHome -T playground playground
git svn clone svn::/server.address:port/RepositoryHome -T playground_dev playground_dev
cd playground
git fetch ../playground_dev trunk:playground_dev
cd ..
rm -rf playground_dev
The last command fetches branch "trunk" from directory playground_dev
to a new branch "playground_dev" in the current dir. 最后一个命令获取从目录分支“主干” playground_dev
在当前目录一个新的分支“playground_dev”。
The problem can be solved in 2 steps. 该问题可以通过2个步骤解决。
First, delete all errroneously-tracked branches. 首先,删除所有错误跟踪的分支。
Add correct branches to repository. 将正确的分支添加到存储库。
To delete offending remote references, one can find them with git branch -r
, and then remove with git branch -D
. 要删除有问题的远程引用,可以使用git branch -r
找到它们,然后使用git branch -D
删除它们。
I haven't found "proper" command-line based solution for second step, but fortunately git-svn documentation, more specifically Configuration section gives enough details to do things by hand. 我还没有找到用于第二步的基于“适当”命令行的解决方案,但是幸运的是git-svn文档,更具体地说是Configuration部分提供了足够的详细信息来手动执行操作。
Most important thing is, one cannot just set a single branch to track svn remote; 最重要的是,不能仅仅设置一个分支来跟踪svn remote; in configuration only "branches" key is recognized, which necessitates usage of wildcard substitution. 在配置中,仅识别“分支”键,这需要使用通配符替换。
So, one can just add another svn remote - by hand, in .git/config
, copying one that is already present, changing remote name and value of "fetch" key. 因此,只需在.git/config
手动添加另一个svn remote,复制已存在的svn,即可更改远程名称和“ fetch”键的值。 That way one can setup a branch that corresponds to a single remote svn branch and work as usual after. 这样一来,您可以设置与单个远程svn分支相对应的分支,然后照常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.