Skip to contentSkip to conversation

Add SVN->Git conversion example to documentation

PATCH In review Heikki Orsila 4 participants 4 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add SVN->Git conversion example to documentation

---
This is the third round. Added some commands to clean up the repository, and set fetch heads. Thanks to Miklos Vajna for feedback.

 Documentation/git-svn.txt |   41 ++++++++++++++++++++++++++++++++++++++---
 1 files changed, 38 insertions(+), 3 deletions(-)
Documentation/git-svn.txt +38 -3
index f4cbd2f..26e00c5 100644
@@ -11,9 +11,12 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-git-svn is a simple conduit for changesets between Subversion and git.
-It is not to be confused with linkgit:git-svnimport[1], which is
-read-only.
+git-svn is a simple bidirectional conduit for changesets between
+Subversion and git. It is used to develop projects with Git tools,
+but commit changes to a Subversion repository. It can also be used to
+convert a Subversion repository to a Git repository. It should not
+be confused with linkgit:git-svnimport[1], which does Subversion to
+Git conversion, but not the other direction.
 
 git-svn was originally designed for an individual developer who wants a
 bidirectional flow of changesets between a single branch in Subversion
@@ -520,6 +523,38 @@ have each person clone that repository with 'git clone':
 	git-svn rebase
 ------------------------------------------------------------------------
 
+CONVERTING A SUBVERSION REPOSITORY TO A GIT REPOSITORY
+------------------------------------------------------
+
+When converting a Subversion repository to a Git repository
+--no-metadata removes "git-svn-id:" comments from the log.
+-A option is used to convert SVN pseudonyms to real names
+and email addresses. The whole repository, or a part of it can be
+converted. Two examples below show how to convert the whole repo
+with all branches, or only the SVN trunk.
+
+------------------------------------------------------------------------
+# Convert all branches of an SVN repository to a Git repository:
+
+	git svn clone --no-metadata -A authors.txt SVN_URL foo.git
+
+# Convert only the trunk of an SVN repository to a Git repository:
+
+	git svn clone --no-metadata -A authors.txt SVN_URL/trunk foo.git
+------------------------------------------------------------------------
+After that, the new repository should be cleaned, and fetch heads should
+be set.
+------------------------------------------------------------------------
+	cd foo.git/.git
+	rm -rf svn
+	git config --remove-section svn-remote.svn
+	git config remote.origin.url .
+	git config remote.origin.fetch +refs/remotes/tags/*:refs/tags/*
+	git config --add remote.origin.fetch +refs/remotes/*:refs/heads/*
+	git fetch
+	git gc
+------------------------------------------------------------------------
+
 REBASE VS. PULL/MERGE
 ---------------------
 
Signature · 1 line
1.5.5.1.1.ga5e5c
#1 lore raw

Documentation/git-svn.txt have each person clone that repository with 'git clone': · line 548

Quoted 4 lines · Heikki Orsila
Documentation/git-svn.txt +4 -0
+After that, the new repository should be cleaned, and fetch heads should
+be set.
+------------------------------------------------------------------------
+	cd foo.git/.git

Heh, I was confused. foo.git is usually a bare repo, if the repo has a working directory as well, then just call it foo.

And then: if you convert an svn repo to a git one, don't you want to convert it to a bare repo?

I haven't tried git-svn clone but the following will work for sure:

git --bare init
git --bare svn init -s URL
git --bare svn fetch

Documentation/git-svn.txt have each person clone that repository with 'git clone': · line 555

Quoted 7 lines
Documentation/git-svn.txt +7 -0
+	rm -rf svn
+	git config --remove-section svn-remote.svn
+	git config remote.origin.url .
+	git config remote.origin.fetch +refs/remotes/tags/*:refs/tags/*
+	git config --add remote.origin.fetch +refs/remotes/*:refs/heads/*
+	git fetch
+	git gc

If you remove the svn dir, why don't you remove refs/remotes as well? (Probably via update-ref since git svn will pack refs before it ends for big repos, I think.)

Also I think it would be a good idea to give a hint how to do incremental updates. Something like not deleting the svn dir and using git --bare svn fetch; git fetch.

PS: I'm not a git-svn contributor or anything, just thought I give you some advices, I hope it helped. :-)

#2 lore raw
In reply to Heikki Orsila
Quoted 13 lines · Heikki Orsila

---
This is the third round. Added some commands to clean up the repository, and set fetch heads. Thanks to Miklos Vajna for feedback.

 Documentation/git-svn.txt |   41 ++++++++++++++++++++++++++++++++++++++---
 1 files changed, 38 insertions(+), 3 deletions(-)
Documentation/git-svn.txt +0 -0
index f4cbd2f..26e00c5 100644

Documentation/git-svn.txt SYNOPSIS · line 16

Quoted 9 lines
Documentation/git-svn.txt +3 -3
@@ -11,9 +11,12 @@ SYNOPSIS
 
 DESCRIPTION
 -----------
-git-svn is a simple conduit for changesets between Subversion and git.
-It is not to be confused with linkgit:git-svnimport[1], which is
-read-only.
+git-svn is a simple bidirectional conduit for changesets between
+Subversion and git. It is used to develop projects with Git tools,
+but commit changes to a Subversion repository. It can also be used to

That is correct but doesn't the above give a false impression that commits are only made on subversion side and never on git side?

Documentation/git-svn.txt SYNOPSIS · line 19

Quoted 3 lines
Documentation/git-svn.txt +3 -0
+convert a Subversion repository to a Git repository. It should not
+be confused with linkgit:git-svnimport[1], which does Subversion to
+Git conversion, but not the other direction.

We do not ship nor document svnimport anymore and linkgit: there is actively wrong. People seem to be confused with ancient documents still floating on the Web that talk about svnimport, and I think it is a good idea to try to clear the confusion here, but perhaps...

... with the deprecated git-svnimport, which was used for one-way conversion from Subversion to git.

Documentation/git-svn.txt have each person clone that repository with 'git clone': · line 531

Quoted 10 lines
Documentation/git-svn.txt +6 -0
@@ -520,6 +523,38 @@ have each person clone that repository with 'git clone':
 	git-svn rebase
 ------------------------------------------------------------------------
 
+CONVERTING A SUBVERSION REPOSITORY TO A GIT REPOSITORY
+------------------------------------------------------
+
+When converting a Subversion repository to a Git repository
+--no-metadata removes "git-svn-id:" comments from the log.
+-A option is used to convert SVN pseudonyms to real names

Anything that user usually would type on the command line it is preferred to typeset with quoted like this, so "--no-metadata" and "-A option".

It is not --no-metadata "removes". git-svn adds cruft because it wants to use it for bidi operation, but --no-metadata prevents it from doing so.

#3 lore raw
Quoted 9 lines · Junio C Hamano

Documentation/git-svn.txt SYNOPSIS · line 16

Quoted 6 lines
Documentation/git-svn.txt +3 -3
-git-svn is a simple conduit for changesets between Subversion and git.
-It is not to be confused with linkgit:git-svnimport[1], which is
-read-only.
+git-svn is a simple bidirectional conduit for changesets between
+Subversion and git. It is used to develop projects with Git tools,
+but commit changes to a Subversion repository. It can also be used to

That is correct but doesn't the above give a false impression that commits are only made on subversion side and never on git side?

Hmm.. I'll try to make it more explicity. Will send another patch soon.

Quoted 8 lines

Documentation/git-svn.txt SYNOPSIS · line 19

Quoted 3 lines
Documentation/git-svn.txt +3 -0
+convert a Subversion repository to a Git repository. It should not
+be confused with linkgit:git-svnimport[1], which does Subversion to
+Git conversion, but not the other direction.

We do not ship nor document svnimport anymore and linkgit: there is actively wrong. People seem to be confused with ancient documents still floating on the Web that talk about svnimport, and I think it is a good idea to try to clear the confusion here, but perhaps...

OK, I will not mention svnimport in the next patch.

Quoted 17 lines

... with the deprecated git-svnimport, which was used for one-way conversion from Subversion to git.

Documentation/git-svn.txt have each person clone that repository with 'git clone': · line 531

Quoted 10 lines
Documentation/git-svn.txt +6 -0
@@ -520,6 +523,38 @@ have each person clone that repository with 'git clone':
 	git-svn rebase
 ------------------------------------------------------------------------
 
+CONVERTING A SUBVERSION REPOSITORY TO A GIT REPOSITORY
+------------------------------------------------------
+
+When converting a Subversion repository to a Git repository
+--no-metadata removes "git-svn-id:" comments from the log.
+-A option is used to convert SVN pseudonyms to real names

Anything that user usually would type on the command line it is preferred to typeset with quoted like this, so "--no-metadata" and "-A option".

Quoted 3 lines

It is not --no-metadata "removes". git-svn adds cruft because it wants to use it for bidi operation, but --no-metadata prevents it from doing so.

OK

Signature · 3 lines
Heikki Orsila
[email protected]
http://www.iki.fi/shd