git svn clone SVN仓库单个目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17865386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:38:30  来源:igfitidea点击:

git svn clone of a single directory of SVN repository

gitsvnversion-controlgit-svn

提问by oconnor0

I am attempting to use git svnto clone a single directory of a SVN repository into a Git repository.

我正在尝试将git svnSVN 存储库的单个目录克隆到 Git 存储库中。

If I use git svn clone svn+ssh://path/to/repo/trunk/directory, I get a Git repo without branches that mirror the branches in the source SVN repo.

如果我使用git svn clone svn+ssh://path/to/repo/trunk/directory,我会得到一个没有分支的 Git 存储库,这些分支镜像源 SVN 存储库中的分支。

If I use git svn --stdlayout svn+ssh://path/to/repo/trunk/directory, I get an empty Git repo. The following is the output of the command:

如果我使用git svn --stdlayout svn+ssh://path/to/repo/trunk/directory,我会得到一个空的 Git 存储库。以下是命令的输出:

Initialized empty Git repository in /directory/.git/
Using higher level of URL: svn+ssh://path/to/repo/trunk/directory => svn+ssh://path/to/repo
W: Ignoring error from SVN, path probably does not exist: (160013): Filesystem has no item: File not found: revision 100, path '/trunk/directory'
W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
This may take a while on large repositories

I had read that the way to fix the above was to add a revision range like -r 1000:HEAD, this still produces an empty repo. The output is:

我读过解决上述问题的方法是添加一个修订范围,例如-r 1000:HEAD,这仍然会产生一个空的回购。输出是:

Initialized empty Git repository in /directory/.git/
Using higher level of URL: svn+ssh://path/to/repo/trunk/directory => svn+ssh://path/to/repo

Any ideas on how to clone a subdirectory of an SVN repository using git-svn that still grabs all of the branches & tags from the source SVN respository?

关于如何使用 git-svn 克隆 SVN 存储库的子目录的任何想法仍然从源 SVN 存储库中获取所有分支和标签?

回答by Mykola Gurov

You don't want standard layout, you want something like this:

你不想要标准布局,你想要这样的东西:

git svn clone svn+ssh://path/to/repo/ --trunk=trunk/directory --branches=branches/*/directory --tags=tags/*/directory

回答by Adrian Constantin

Prepare and enter the local project directory:

准备并进入本地项目目录:

mkdir local/project/path
cd local/project/path

Initialize the local git repository with svn remote and fetch the data:

使用 svn remote 初始化本地 git 存储库并获取数据:

git svn init http://my_svn_server.com/repository/project/location
git svn fetch

Credit goes to Gabriel Salda?a: http://blog.gabrielsaldana.org/using-git-with-subversion-repository-subdirectory/

归功于 Gabriel Salda?a:http: //blog.gabrielsaldana.org/using-git-with-subversion-repository-subdirectory/