Search code examples
gitsvngit-svn

git svn clone [with Single File]


I know I can use git-svn to clone a directory into a new Git Repo, but how can I use git-svn to clone a single file into a new Git repo?

I have a requirement to split up my SVN repository into several GIT repos and I need to clone certain directories into new Git Repositories. Using git-svn I am able to use the following command for directories:

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

but when I try:

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

it does not work, it gives me the following output:

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.

Is there anyway to clone a single file into a new Git Repo?

(I am using this version of GIT: https://github.com/git-for-windows/git/releases/download/v2.8.3.windows.1/Git-2.8.3-32-bit.exe)


Solution

  • The short answer is that you cannot do this exactly as you want to, but there are some way to do it slightly differently :

    If what you want to do is a migration from svn to git, what I recommend is that you break down you repositories within svn, then you will be able to use git svn clone on each folder. But you would lose the ability to commit back to the svn repo from your new git repo (using git svn dcommit).

    Another solution is to do a sparse checkout : doc, see also some details in Sparse checkout in Git 1.7.0? . But you would still have to put the whole content of your directory in the newly created git repository, even it you don't see it on the working directory.