git svn:仅克隆最新修订版

问题:

你想使用 git-svn 克隆 SVN 仓库,但你不想克隆整个历史(可能相当慢),只想克隆最新修订版。

解决方案

有关如何获取远程仓库最新 SVN 修订版的说明,请参见此文章。你可以在 shell 中使用此命令为 git-svn clone-r 选项生成参数:

git-svn-clone-latest.sh
git svn clone -r `svn info <Repository URL> | grep Revision | cut -d' ' -f2` <Repository URL> <Target path>

你也可以使用此 bash 脚本:

gitsvnone.sh
#!/bin/bash
# 用法:./gitsvnone.sh <SVN 仓库 URL> [<目标目录>]
git svn clone -r `svn info $1 | grep Revision | cut -d' ' -f2` $1 $2

Check out similar posts by category: Git, Shell, Subversion, Version Management