Converting from svn to git

8 messages, 4 authors, 2016-06-15 · open the first message on its own page

Converting from svn to git

From: David Neu <hidden>
Date: 2016-06-15 22:45:07

Hi,

I'm trying to move an svn repo to git.  I'm not going to be committing
back to the svn repo, but will simply retire it and use git.

The issue I'm having is that the svn repo has sub directories that I'd
like to be separate git repos.

I can easily accomplish this for the sub directories like this:

git-svn clone svn-url/subdir1
git-svn clone svn-url/subdir2
etc.

but for the files in the base directory

git-svn clone svn-url

pulls the entire directory tree.

Is there a git-svn strategy similar to git-svnimport -P that would do the trick?
My git version 1.5.6.4 doesn't include git-svnimport, and I'm getting
the impression
it's be deprecated.

Many thanks for any help!

Cheers,
David

Re: Converting from svn to git

From: Miklos Vajna <hidden>
Date: 2016-06-15 22:45:07

On Sun, Aug 10, 2008 at 09:11:43AM -0400, David Neu [off-list ref] wrote:
Is there a git-svn strategy similar to git-svnimport -P that would do the trick?
My git version 1.5.6.4 doesn't include git-svnimport, and I'm getting
the impression
it's be deprecated.
Sure, it is. Though if you _really_ need it, it's still under
/contrib/examples.

Anyway, if you do a single conversion, then probably speed does not
matter a lot; I would do a full import then use the subdirectory-filter
of git filter-branch do drop everything outside the subdirectory.

Re: Converting from svn to git

From: David Neu <hidden>
Date: 2016-06-15 22:45:07

Thanks for the reply - this looks like what I'd need, but
I can't see how to keep the contents of the base dir and
lose the subdirs, e.g.

$ git-filter-branch --subdirectory-filter . HEAD

removes all subdirs and the contents of the base dir.

So, I figure I'd remove each subdir, using

$ git-filter-branch --tree-filter 'rm -rf subdir1/' HEAD

but this complains if subdir1 contains subdirectories, it
says: Namespace refs/original/ not empty

Many thanks!

Cheers,
David


On Sun, Aug 10, 2008 at 9:24 AM, Miklos Vajna [off-list ref] wrote:
On Sun, Aug 10, 2008 at 09:11:43AM -0400, David Neu [off-list ref] wrote:
quoted
Is there a git-svn strategy similar to git-svnimport -P that would do the trick?
My git version 1.5.6.4 doesn't include git-svnimport, and I'm getting
the impression
it's be deprecated.
Sure, it is. Though if you _really_ need it, it's still under
/contrib/examples.

Anyway, if you do a single conversion, then probably speed does not
matter a lot; I would do a full import then use the subdirectory-filter
of git filter-branch do drop everything outside the subdirectory.

Re: Converting from svn to git

From: Michael J Gruber <hidden>
Date: 2016-06-15 22:45:07

David Neu venit, vidit, dixit 10.08.2008 16:54:
Thanks for the reply - this looks like what I'd need, but
I can't see how to keep the contents of the base dir and
lose the subdirs, e.g.

$ git-filter-branch --subdirectory-filter . HEAD

removes all subdirs and the contents of the base dir.

So, I figure I'd remove each subdir, using

$ git-filter-branch --tree-filter 'rm -rf subdir1/' HEAD

but this complains if subdir1 contains subdirectories, it
says: Namespace refs/original/ not empty
It complains because filter-branch stores the original refs in that 
namespace, and on the second filter-branch run it wants to do this 
again. You can avoid this by using the "-f" option to filter-branch, or 
by removing all subsirs in one go ("rm -rf subdir1 subdir2..."). Also, 
you might want to rewrite all refs ("--all"), not just HEAD.

Michael

Re: Converting from svn to git

From: David Neu <hidden>
Date: 2016-06-15 22:45:07

That's great - thanks to everyone!

On Sun, Aug 10, 2008 at 11:32 AM, Michael J Gruber
[off-list ref] wrote:
David Neu venit, vidit, dixit 10.08.2008 16:54:
quoted
Thanks for the reply - this looks like what I'd need, but
I can't see how to keep the contents of the base dir and
lose the subdirs, e.g.

$ git-filter-branch --subdirectory-filter . HEAD

removes all subdirs and the contents of the base dir.

So, I figure I'd remove each subdir, using

$ git-filter-branch --tree-filter 'rm -rf subdir1/' HEAD

but this complains if subdir1 contains subdirectories, it
says: Namespace refs/original/ not empty
It complains because filter-branch stores the original refs in that
namespace, and on the second filter-branch run it wants to do this again.
You can avoid this by using the "-f" option to filter-branch, or by removing
all subsirs in one go ("rm -rf subdir1 subdir2..."). Also, you might want to
rewrite all refs ("--all"), not just HEAD.

Michael

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Re: Converting from svn to git

From: David Neu <hidden>
Date: 2016-06-15 22:45:08

OK, I did

$ git-filter-branch --tree-filter 'rm -rf subdir1/ subdir2/ subdir3/' -- --all

which looks good, except when I open gitk, I still see "empty" commits
that correspond to subdir1/, subdir2/ and subdir3/.

Is there anyway to remove those?

Many thanks!

Cheers,
David

On Sun, Aug 10, 2008 at 11:48 AM, David Neu [off-list ref] wrote:
That's great - thanks to everyone!

On Sun, Aug 10, 2008 at 11:32 AM, Michael J Gruber
[off-list ref] wrote:
quoted
David Neu venit, vidit, dixit 10.08.2008 16:54:
quoted
Thanks for the reply - this looks like what I'd need, but
I can't see how to keep the contents of the base dir and
lose the subdirs, e.g.

$ git-filter-branch --subdirectory-filter . HEAD

removes all subdirs and the contents of the base dir.

So, I figure I'd remove each subdir, using

$ git-filter-branch --tree-filter 'rm -rf subdir1/' HEAD

but this complains if subdir1 contains subdirectories, it
says: Namespace refs/original/ not empty
It complains because filter-branch stores the original refs in that
namespace, and on the second filter-branch run it wants to do this again.
You can avoid this by using the "-f" option to filter-branch, or by removing
all subsirs in one go ("rm -rf subdir1 subdir2..."). Also, you might want to
rewrite all refs ("--all"), not just HEAD.

Michael

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Re: Converting from svn to git

From: Michael J Gruber <hidden>
Date: 2016-06-15 22:45:10

David Neu venit, vidit, dixit 11.08.2008 19:46:
OK, I did

$ git-filter-branch --tree-filter 'rm -rf subdir1/ subdir2/ subdir3/' -- --all

which looks good, except when I open gitk, I still see "empty" commits
that correspond to subdir1/, subdir2/ and subdir3/.

Is there anyway to remove those?
A while ago I "complained" that rebase would skip empty commits. You 
might experiment with that. Alternatively, the following works for me:

git filter-branch --commit-filter 'cmd="git commit-tree"; test `git show 
--pretty=oneline $GIT_COMMIT|wc -l` = 1 && cmd="skip_commit"; $cmd "$@"' 
-- --all

This skips all commits which introduce no diff. It will not remove 
branches or tags which are related only to those subdirs.

I am sure there will be more elegant ways to do that (esp. the test with 
wc).

Michael

Re: Converting from svn to git

From: Sam Vilain <hidden>
Date: 2016-06-15 22:45:10

On Fri, 2008-08-15 at 15:58 +0200, Michael J Gruber wrote:
A while ago I "complained" that rebase would skip empty commits. You 
might experiment with that. Alternatively, the following works for me:

git filter-branch --commit-filter 'cmd="git commit-tree"; test `git show 
--pretty=oneline $GIT_COMMIT|wc -l` = 1 && cmd="skip_commit"; $cmd "$@"' 
-- --all

This skips all commits which introduce no diff. It will not remove 
branches or tags which are related only to those subdirs.

I am sure there will be more elegant ways to do that (esp. the test with 
wc).
something like this should work:

  --commit-filter 'if [ "$1" = `git rev-parse HEAD^{tree}` ]; then
skip_commit "$@"; else git commit-tree "$@"; fi'

Sam.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help