git svn clone [单个文件]

git svn clone [with Single File]

我知道我可以使用 git-svn 将一个目录克隆到一个新的 Git 仓库中,但是我如何使用 git-svn 克隆一个 单个文件 到一个新的 Git 仓库?

我需要将我的 SVN 存储库拆分为几个 GIT 存储库,并且我需要将某些目录克隆到新的 Git 存储库中。使用 git-svn 我可以对目录使用以下命令:

git svn clone "svnRepo/folderName/" "C:/newGitRepo/FolderName"

但是当我尝试时:

git svn clone "svnRepo/folderName/style.css" "C:/newGitRepo/FolderName"

它不起作用,它给我以下输出:

Initialized empty Git repository in C:/newGitRepo/FolderName/.git/
W: Ignoring error from SVN, path probably does not exist: (160013): Filesystem has no item: '...trunk/folderName/style.css' path not found
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
Invalid filesystem path syntax: Cannot replace a directory from within at /mingw64/share/perl5/site_perl/Git/SVN/Ra.pm line 308.

是否可以将单个文件克隆到新的 Git 存储库中?

(我正在使用这个版本的GIT:https://github.com/git-for-windows/git/releases/download/v2.8.3.windows.1/Git-2.8.3-32-bit.exe

简短的回答是,您不能完全按照自己的意愿执行此操作,但可以通过一些稍微不同的方式来执行此操作:

如果您想做的是从 svn 迁移到 git,我建议您在 svn 中分解存储库 ,那么您将能够在每个文件夹上使用 git svn clone。 但是 你将失去从新的 git 仓库提交回 svn 仓库的能力(使用 git svn dcommit).

另一个解决方案是稀疏结帐doc, see also some details in Sparse checkout in Git 1.7.0? . 但是您仍然必须将目录的全部内容放入新创建的 git 存储库中,即使您在工作目录中看不到它。