A command-line tool that automates the task of creating a Git mirror for a SVN repo, and keeping it up-to-date.
This is direct Python port of git-svn-mirror written in Ruby by Eloy Duran. The guide below is a direct copy of README.md authored by Eloy Duran.
- mloskot/pygit-svn-mirror@8b50339f7b8950a2919b8ec8ab02a2d986bdf94b - first version of the Python port based on alloy/git-svn-mirror@42f52463ea0cc88bf892e39b48693855ff3dabc6
Figuring this stuff out is a pain in the bum, in my opinion, and its probably not even done yet. So please do contribute! Also, if I would keep doing this by hand, I would forget how to do it, a few weeks down the line.
- Python 3+
Simply, clone pygit-svn-mirror and add the
lib directory to
git-svn.mirror.py script from command line.
git-svn.mirror.py --help and the guide below to learn how to use it.
NOTE: Below, I use
pygit-svn-mirror command. This is placeholder for Shell
script proxy which I'm going to add at some point.
On Windows, you can copy
bin\pygit-svn-mirror.bat script to location included
in your PATH or you can add the
bin\ directory to PATH.
Next, edit the script and update
PYGITSVN variable with location to your
local clone pygit-svn-mirror repository.
This way, you can run the tool through
Configure the ‘workbench’
To mirror a SVN repo, first the local ‘workbench’ repo has to be configured. This ‘workbench’ is the GIT repo where the SVN revisions will be stored and from where these revisions will be pushed to the remote mirror GIT repo.
Start by creating the directory:
$ mkdir -p /path/to/workbench
Then initialize the ‘workbench’:
$ cd /path/to/workbench $ pygit-svn-mirror init --from=http://svn-host/repo_root --to=git@git-host:user/mirror.git
This will create a ‘bare’ GIT repo, configure the SVN and GIT remotes, fetch the revisions from the SVN remote, and compact the ‘workbench’ by running the GIT garbage collector.
It can often be handy to supply an authors file, with the --authors-file option, which is used to migrate user names to GIT names and email addresses. The entries in this file should look like:
svn-user-name = User Name <firstname.lastname@example.org>
To push the latest changes from the SVN repo to the GIT repo, run the following command from the ‘workbench’ repo:
$ pygit-svn-mirror update
Or by specifying the path to ‘workbench’ repos:
$ pygit-svn-mirror update -w /path/to/workbench1
You will probably normally not want to perform this step by hand. You can solve this by adding this command as a cron job, in which case you can silence the tool with the --silent option.
‘init’ --help banner
Usage: git-svn-mirror.py init [mandatory options] [options] Mandatory options are --from and --to. Use --help to find details. Options: --version show program's version number and exit -h, --help show this help message and exit -s, --silent Silent mode. -f URI, --from=URI The location of the SVN repository that is to be mirrored. -t URI, --to=URI The location of the Git repository that is the mirror. -w PATH, --workbench=PATH The location of the workbench repository. Defaults to the current work dir. -a PATH, --authors-file=PATH An optional authors file used to migrate SVN usernames to Git format.
‘update’ --help banner
Usage: git-svn-mirror.py update [options] Options: --version show program's version number and exit -h, --help show this help message and exit -s, --silent Silent mode. -w PATH, --workbench=PATH The location of the workbench repository. Defaults to the current work dir.
Once you've made your great commits:
- Fork pygit-svn-mirror
- Create a topic branch -
git checkout -b my_branch
- Push to your branch -
git push origin my_branch
- Create an Issue with a link to your branch
- That’s it!
Thanks to Eloy Duran for the original git-svn-mirror written in Ruby.
License In Three Lines (LITL)
© 2011 Mateusz Loskot <email@example.com> © 2010 Eloy Duran <firstname.lastname@example.org> (author of git-svn-mirror in Ruby) You may use these works without restrictions, as long as this paragraph is included. The work is provided “as is”. There is NO warranty of any kind, express or implied.