我正在尝试使用git svn
将SVN存储库的单个目录克隆到Git存储库中。
如果我使用git svn clone svn+ssh://path/to/repo/trunk/directory
,我会得到一个没有分支的Git仓库,它反映了源SVN仓库中的分支。
如果我使用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
我曾经读过,解决上述问题的方法是添加像-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
关于如何使用git-svn克隆SVN存储库的子目录的任何想法仍然抓住所有分支&来自源SVN存储库的标签?
答案 0 :(得分:53)
你不需要标准布局,你想要这样的东西:
git svn clone svn+ssh://path/to/repo/ --trunk=trunk/directory --branches=branches/*/directory --tags=tags/*/directory
答案 1 :(得分:28)
准备并进入本地项目目录:
mkdir local/project/path
cd local/project/path
使用svn remote初始化本地git存储库并获取数据:
git svn init http://my_svn_server.com/repository/project/location
git svn fetch
归功于GabrielSaldaña:http://blog.gabrielsaldana.org/using-git-with-subversion-repository-subdirectory/