Change the branch in GitHub to which Subgit maps the SVN trunk branch?

Hi,

I’ve got Subgit set up such that it replicates a local SVN repository. I also setup a mirroring of that in GitHub.

“Trunk” branch in SVN is mirrored to “Master” in GitHub.

We recently introduced a rule to force pull requests to be created before accepting changes into the master. Unfortunately this broke the sync of SubGit since it cannot push the changes directly to Master. I was thinking if there is a way to make SubGit sync the trunk to another branch say master_svn and then we will create pull requests from master_svn to master in GitHub.

Something like.

SVN (Trunk) -> SubGit (Master_SVN) -> GitHub (Master_SVN)
                      (Master)     <- GitHub (Master)

I understand that we’ll need to pull the GitHub (Master) into SubGit (Master) manually.

Hi Ravi,

yes, it’s surely possible to couple the trunk to another Git branch, it can be done but setting SubGit’s mapping configuration in the following way:

[svn]
    trunk = trunk:refs/heads/master_svn
    …

leaving the rest of the mapping lines untouched. Note, however, that if you would set a wildcard branches mapping like follows:

branches = branches/*:refs/heads/*

or in a similar way, then it will pick up the master branch and mirror it to master in SVN, so better either exclude it with svn.excludeBranches feature or set an explicit branches mapping so the the master branch is not included in the mapping configuration.
If it’s needed to differentiate SVN-mirrored and Git-only branches within single SubGit repositories, we usually recommend using different Git namespaces for SVN branches, setting the mapping like this:

[svn]
    trunk = trunk:refs/heads/svn/master_svn
    branches = branches/*:refs/heads/svn/*
    tags = tags:refs/tags/svn/*

this approach allows using usual Git branches and not interfere with SVN ones.

Note, though, that such a mapping configuration changes are not possible to apply on the fly to an existing mirror since such changes require the repository rebuild, so either this repository should be rebuild or a new one created with new mapping.

Hope it will help.

Hi Ildar,

Thanks for the quick reply.

Just to clarify, I need the svn.excludeBranches to avoid the Master from GitHub going back in SVN, right? Would the following work?

svn.excludeBranches = master

Good point about differentiating SVN-mirrored and Git only branches but at the moment only the Master seems necessary.

Regards,
Ravi

Hi Ravi,

yes, that’s correct, to avoid the master going back to SVN. If may happen if the trunk is mapped to another branch, not the master, and at the same time there is a wildcard mapping that may include master. The svn.excludeBranches' setting is correct yet the svnpart there means the[svn]` section of the configuration file which is already present there, so just add the setting to the section:

[svn]
    trunk = trunk:refs/heads/master_svn
    …
    excludeBranches = master

Just in case, here is more about branches exclusion:

TMate SubGit: Branches and tags mapping