There is an open source project I want to checkout and contribute to. The main repository is SVN but I want to work in Git. Is this possible?
Most of my searches turns up guides where you move from SVN to Git (or the other way around) and dont look back.
Assume that the original authors have no interest whatsoever in learning anything other than SVN.
[Update] I dont have, nor do I want to have, commit access to the SVN repository. Im looking for workarounds for that.
[Update2] If patches are indeed my only option, are there any additional caveats I should be aware of?
You can clone a subversion repository to your machine using git svn clone <SVN repo URL> . The code will be available as a git repository. You can do your work there and make local commits as you please. There is a command line option to get a "shallow" checkout rather than the entire repository which is often useful.
You can either store your repositories locally and access them using the file:// protocol or you can place them on a server and access them with the http:// or svn:// protocols. The two server protocols can also be encrypted. You use https:// or svn+ssh:// , or you can use svn:// with SASL.
Check out files from Subversion repositoryIn the Get from Version Control dialog, click Add Repository Location and specify the repository URL. Click Check Out. In the dialog that opens, specify the destination directory where the local copy of the repository files will be created, and click OK.
Luckily there's git-svn for exactly this purpose. It enables you to use git locally while also being able to check in to SVN when you wish to do so. It's fairly straightforward and there are lots of information if you search for git-svn
here or via Google.
There's a tutorial at http://flavio.castelli.name/howto_use_git_with_svn that you might want to look at first.
Edit: To generate SVN compatible diffs you can use git diff --no-prefix
. Note however that this format is not compatible with TortoiseSVN. If compatibility is needed you would have to use some sort of shell script; see example here: http://mojodna.net/2009/02/24/my-work-git-workflow.html
Edit: One potential downside of git-svn is that it does not handle svn externals. You would have to handle those yourself.
Good luck!
Keeping a Git repository in sync with a Subversion repository is really easy:
Clone the Subversion repository (in this simple example I am ignoring branches/tags)
$ git svn clone https://url/to/repo/trunk
Keep up-to-date with the Subversion trunk:
$ git svn rebase
Now, if you had commit access to the Subversion repo, you could push your changes:
$ git commit
$ git svn dcommit
Otherwise, submitting a patch is your only option, if the committers to the Subversion repository have no interest in using Git:
$ git diff 1cc92b96 > my_patch.patch
In this case it's obviously best not to make commits to the branch you are syncing with the Subversion repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With