1

I have setup subgit to mirror one assembla svn repository to git. I would like only to use svn->git way. Anyway I don't have rights to commit to svn repo so subgit comes with error messages when trying to sync back to svn (git->svn). Is there any way to accomplish this?

dseferlis
  • 467
  • 2
  • 6
  • 11
  • 1
    Do you want to sync svn->git and push to Git at the same time? In general this is impossible if the Git push changes branches that are in sync with SVN. Suppose you have some/file in SVN and Git. Then you push to Git a change to it, so now Git has some/file with different content. If this change were not translated to SVN, someone can now commit to SVN a change to that some/file,and the change now can't be applied to Git's some/file because it is different. What you can do is to setup SubGit to sync some namespace (see trunk/branches/tags options) and use another branches namespace for pushes. – Dmitry Pavlenko Apr 02 '15 at 06:30
  • I m making changes a branch don't exist on svn. So what i want is main branch to be up-to-date from svn and to merge to my branch by time to time. – dseferlis Apr 02 '15 at 07:30
  • @DmitryPavlenko how i can tell subgit to ignore a git branch from sending to svn? – dseferlis Apr 02 '15 at 08:33
  • See my answer below. To ignore a branch you can use approach 3. – Dmitry Pavlenko Apr 02 '15 at 11:08

1 Answers1

1

It is impossible to support pushing some Git branching without translating them to SVN while keeping them in sync with SVN branches. So the solution would be to work with one set of Git branches while keeping another set of branches in sync with SVN. Those synchronized branches should be manually periodically merged to the branches of the first set. There're several ways to do that using SubGit.

Approach 1. Use separate namespace. For example you can sync refs/heads/svn/* and refs/tags/svn/* to SVN while working with refs/heads/*. To do that use the following options in SubGit config file:

trunk = trunk:refs/heads/svn/master
branches = branches/*:refs/heads/svn/*
tags = tags/*:refs/tags/svn/*
shelves = shelves/*:refs/shelves/svn/*

So when you clone such a repository, SVN trunk is translated to refs/remotes/origin/svn/master, and you should periodically merge that branch manually using git merge to have your local refs/heads/master be more or less up-to-date with SVN.

Approach 2. Since SubGit 3.0 (or 3.0.0-EAP version until it is released) you can restrict all branches you synchronize with SVN to one or several branches (other branches/tags/shelves options are removed):

trunk = trunk:refs/heads/master
branches = branches/branch1:refs/heads/branch1
branches = branches/branch2:refs/heads/branch2

After that refs/heads/branch1, refs/heads/branch2, and refs/heads/master will be synchronized with SVN, and refs/heads/branch3 won't be.

Approach 3. Since SubGit 3.0 (or 3.0.0-EAP version until it is released) you can exclude one or more branches from synchronization:

trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
tags = tags/*:refs/tags/*
shelves = shelves/*:refs/shelves/*
excludeBranches = branches/nosync1
excludeBranches = branches/nosync2

This configuration syncronizes all refs/heads/* except refs/heads/nosync1 and refs/heads/nosync2, because if they were synchronized, they would be translated to branches/nosync1 and branches/nosync2 which are ignored.

Actually you're not restricted to these approached, but you can mix them depending on your needs.

Dmitry Pavlenko
  • 8,530
  • 3
  • 30
  • 38
  • To be honest i used subgit EAP before see this answer... It would be easier if i had seen this. But anyway i have setup: trunk = trunk:refs/heads/master-svn excludeBranches = master Till now is seems working just fine!!! – dseferlis Apr 02 '15 at 18:42
  • `excludeBranches` option requires SVN path, not Git reference name. For you it has no effect because you exclude from translation a path which is already not translated because you didn't tell SubGit to translate it. – Dmitry Pavlenko Apr 02 '15 at 19:13