tom eustace
tom eustace

Reputation: 1281

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?

Upvotes: 48

Views: 20954

Answers (8)

U007D
U007D

Reputation: 6318

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.

Upvotes: 1

kfriend
kfriend

Reputation: 2614

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.

Upvotes: 16

wspeirs
wspeirs

Reputation: 1413

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

Upvotes: 69

morgue
morgue

Reputation: 11

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.

Upvotes: 1

IRQ
IRQ

Reputation: 326

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.

Upvotes: 1

user245547
user245547

Reputation:

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

Upvotes: 2

tom eustace
tom eustace

Reputation: 1281

Below command did the job:

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

Upvotes: 30

markus
markus

Reputation: 602

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

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

Upvotes: 0

Related Questions