We have got a commercial version of the plugin “SVN Mirror for bitbucket server” which we have been using for the last 2 years to migrate our SVN repositories to BitBucket.
When we Mirror an SVN repo to Bitbucket, we understand the sync happens from SVN to Bitbucket and vice-versa. Is our understanding correct?
Is there a way to sync SVN to Bitbucket (one-way sync) ONLY but not Bitbucket to SVN?
yes, you are completely right, SVN Mirror’s Mirror mode means two-way synchronisation between SVN and Bitbucket, both from SVN to Bitbucket and in the opposite direction.
SVN Mirror add-on has no such ‘one-way mode’ mode just because the SVN-to-Git synchronisation is essentially two-way as the mirror will immediately fail in case if a synchronised reference has been edited both in Git and in SVN.
However, it is possible to make a mirrored setup effectively ‘one-way’ mirroring SVN branches to a separate namespace in Git. So, for example, if a mirror is set with the following branches mapping:
so that all the SVN branches and tags are landing in their separate namespace and are not being edited on the Git side, then it would be an effectively one-way mirror. The data imported from SVN can be manually merged from those branches in the separate namespace to regular Git branches – like, from ‘fromsvn/trunk’ to regular master branch.
first of all, I’d like to note there is an error in my previous message, the asterisk symbol in the branches line should be placed on the left side of colon, like this:
branches = branches/*:refs/fromsvn/*
sorry for this typo.
The idea behind this workaround is to separate Git references mirrored to SVN and Git-only references. One of possible ways to perform such a separation is to place mirrored references in a separate Git namespace, so that mirrored branches are in their own namespace (like fromsvn) while regular Git branches are in the default Git’s refs/heads. In such a setup it will be possible to use regular Git branches without any limitations since there are not mirrored – for example, it’s possible to create a main branch, push to it and those new pushes will not be sent to SVN. At the same time, the changes from SVN will be imported to Git repository – for example, changes from SVN’s trunk will appear in Git’s fromsvn/trunk branches, but not directly in the main branch. However, it is possible to manually merge changes from fromsvn/trunk into main. Thus the setup is effectively one-way mirror since changes to regular Git branches are not synchronized to SVN automatically.
Such a setup requires a configuration similar to one I mentioned:
It’s not mandatory to set it exactly like this, but SVN branches must be mapped to branches in their own Git namespaces. If you have already migrated an SVN repository with the configuration similar to what you mentioned:
Then I’m afraid such a repository must be re-imported from scratch with the new configuration; or developers should use separate Git branches for work – like, working/main branch instead of main.