git svn clone results in empty directory

I have an svn repository with project structure:

/root/projectA/trunk
/root/projectA/branches
/root/projectA/tags

/root/projectB/trunk
/root/projectB/branches
/root/projectB/tags 

I want to clone projectA. When I run:

git svn clone -r <revision number>:HEAD <url>/root/projectA

I get no errors and a git repository is created under the new projectA directory. However the directory is empty. Am I missing soemthing?

Answers


My problem was using the -s or --stdlayout because my svn repo did NOT have a standard layout (trunk, branches, tags).


Below command did the job:

  git svn clone -r HEAD <url>/root/projectA 

For anyone including the authors-file option, git svn clone will stop completely if it encounters an author without a lookup value in the supplied authors file. If you're not paying attention, git's "alert" for this may look like the repo has finished cloning, and doesn't state that the process is not complete. The repo's directory will be empty, besides .git.

If you add the missing author, then rerun the exact command, git will continue where it halted.


I've had the same problem and it was solved by using the --no-metadata argument. In your case, this would amount to

git svn clone -r <revision number>:HEAD <url>/root/projectA --no-metadata

If you use the HTTP or HTTPS transports (i.e. your repository URLs start with HTTP[s]), you need to provide a valid SVN username.

git svn clone -s https://svn.example.com/root/projectA --username <SVN username>

-s is an alias for --stdlayout

However, I only had to specify the --username option once and subsequent calls worked without it. I guess it caches the username.


Had a similar issue, executing 'git reset --hard HEAD' in the directory seemed to create the files.

.git/objects was quite large, so I guess the files were imported from svn into git, they just weren't checked out, or something.


In my case, the clone operation wasn't completing properly. git svn clone would fail partway through the checkout. Once I fixed the issue, it automatically did the checkout after the clone operation--no more empty folder.

[Update] Here's what worked in my case:

Attempting git svn clone --preserve-empty-dirs <repo> failed for me. After scouring the net, I found https://www.semitwist.com/articles/article/view/the-better-svn-git-guide, which says, in part:

This part is a bit of an annoyance. From v1.7.7 onward, Git has a --preserve-empty-dirs. Problem is, the damn thing's broken. If you try to use it as-is, the whole operation will likely just fail partway through. It has to be fixed.

First, find your git-svn file:

$ find / 2> /dev/null | grep git-svn

$ find 2>/dev/null / -type f | grep -l "Failed to strip"

For me, it was at /usr/libexec/git-core/git-svn.

Note: It’s not in git-svn any more (at least not in git 2.7.0). I found it in /usr/lib/perl5/vendor_perl/5.22/Git/SVN/Fetcher.pm.

Open the target file in your favorite editor:

sudo <your-favorite-editor> path/to/file

Now, in this git-svn file, search for die "Failed to strip path. ([Depending on your version of git,] it [may] be somewhere near line 4583. Change the die to print and save. Your git-svn is now fixed.

git svn clone --preserve-empty-dirs <repo> should now behave as expected.


I could not chech whether this is working, but try:

git svn clone --stdlayout <url>/root/projectA/

Need Your Help

Adding titles to ViewPager

android android-viewpager

I have set up a ViewPager for swipeable tabs and now I want to add titles at the top of the page to indicate what fragment is being shown.

How to determine the version of android SDK installed in computer?

android sdk android-sdk-tools

How to determine the version of Android SDK installed in my computer?