Mapping between git committers and SVN users

user82057 picture user82057 · Mar 24, 2009 · Viewed 8.9k times · Source

I'm using git-svn to store a "staging" version of some SVN repo, where other users are allowed to pull from this staging repo and commit there changes back to it, then the commits on the staging repo are periodically committed the upstream SVN repo.

I want to know if there's a way to map between the git committers' names and SVN usernames, so that their information would be kept intact when committing back to the SVN repo?

Answer

VonC picture VonC · Mar 24, 2009

Vincent Danen does mention the -A option when using git svn:

So using ~/git as a top-level directory for Git repositories [...] create an authors.txt file.
This file will map the names of Subversion committers to Git authors, resulting in a correct history of the imported Subversion repository.
For projects with a small number of committers, this is quite easy. For larger projects with a lot of committers, this may take some time. The syntax of the file would be:

user = Joe User <[email protected]>
vdanen = Vincent Danen <[email protected]>

The short name is the committer name for Subversion whereas the long form is the user’s full name and e-mail address, as used by Git.

The final step is to clone the Subversion repository, which creates a local Git repository based on it. Assuming your repository uses the standards of /trunk, /tags, and /branches, use:

# git svn clone --no-metadata -A authors.txt -t tags -b branches -T trunk https://svn.example.com/svn/repo

-A<filename>
--authors-file=<filename>

Syntax is compatible with the file used by git-cvsimport:

loginname = Joe User <[email protected]>

If this option is specified and git-svn encounters an SVN committer name that does not exist in the authors-file, git-svn will abort operation.
The user will then have to add the appropriate entry.
Re-running the previous git-svn command after the authors-file is modified should continue operation.

config key: svn.authorsfile

This should work for all git-svn commands, including git-svn dcommit (when you push to SVN) (Note: I have not tested it directly though).

Mohammed Gamal does report (in the comments) it is working, but without the --no-metadata option.