News:

Congratulations!
 You've won the News Item Lottery! Your prize? Reading this news item! :)

Using Git SVN

Started by ACarlotti, April 11, 2019, 03:29:34 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ACarlotti

This is a brief explanation of how I have setup git svn, incorporating aburch's Github mirror. It is probably useful to anyone who wishes to commit to the (Standard) subversion repository directly from Git (which might just be me for now).

1. Clone aburch's mirror. (Basing our commits upon the semi-official mirror could be useful for sharing WIP with others via Git, or incorporating commits from Extended. It is also faster to clone an existing mirror than to build a mirror from scratch.)
git clone https://github.com/aburch/simutrans.git
Alternatively, any other method of adding aburch's mirror as a Git remote will also work; in the case replace origin in the below steps with the name you have used for this repository.

2. Edit the config file .git/config within the newly created project, to add the following lines:

[svn-remote "svn"]
url = svn://servers.simutrans.org
fetch = simutrans/trunk:refs/remotes/origin/master
branch = simutrans/branches/trunk:refs/remotes/origin/master
branches = simutrans/branches/*:refs/remotes/svn/*
tags = simutrans/tags/*:refs/remotes/svn/tags/*
rewriteRoot = svn://tron.homeunix.org/simutrans

url obviously specifies the server (and transfer protocol).
fetch and branch together specify that the svn trunk will be written to origin/master (i.e. the same place as aburch/master in this configuration). I don't understand exactly how, but omitting the former leads to git svn fetch downloading its own copy of trunk, while omitting the latter caused an error.
branches specifies that all other branches are written to the remote branch name svn/*
rewriteRoot is necessary to ensure consistency in the git mirror even after the svn repository moved to another server. This determines the server name used in setting/checking part of the git-svn-id line in each commit.

3. Run git svn fetch. This will fetch the other branches on the svn repository, but will not download the entire trunk because it git will see that we already have it.

From this point, you can develop on top of origin/master as you normally would in Git (mostly). Search for git-svn information online to understand how interacting with svn affects the workflow within Git.


There are a couple of things to note about subsequent interactions with the svn repository.

1. You'll probably have to specify the username somewhere when using dcommit. You can specify it each time using git svn dcommit --username=[username], or configure it in .subversion/config (on Linux; Windows may differ).
2. Whenever you want to fetch the latest commits from the svn repository, you should fetch them via Aburch's mirror (e.g. using git fetch origin master in this case). This should also be done after uploading changes to the svn - this will replace the commits generated directly from the svn repository with ones generated by aburch's mirror. git svn will recognise the commits from aburch's mirror as being derived from the svn revisions, and will not try to overwrite them.



If anyone has any comments, questions or corrections, I'll try to answer them and/or update the above as necessary.

Dwachs

Thanks! Will try this out. Currently, I do development with a local git clone of the svn-server done with smartgit. I could not figure out how to use aburch's clone in this process.
Parsley, sage, rosemary, and maggikraut.