Subgit: avoid to synchronize git branches onto svn
Asked Answered
M

1

4

I am trying to use SubGit but I am facing a problem with branches: I would like branches created under Git to live and die inside Git only. I found this: SubGit: How to exclude branches?, but it says

The troubles come from merge commits: if commit A is the result of merging branch foo into master, then SubGit creates branches/foo on Subversion side for corresponding parent of commit A. . If you'd prefer to not include SubGit generated branches into branches/* namespace, consider using some special branches on Subversion side as well

I don't want to mess with the SVN because I am evaluating Subgit and I don't want to change anything on SVN. I guess I could my goal (meaning, committing to SVN only the merged history and not also the git branch) by rebasing before pushing to the Git repository, but I am afraid this could lead to conflicts when committing back to SVN. Any idea on how I can workaround this, without waiting for SubGit version 2.1 (claimed to do what I want but not in a near future - cit from linked answer: it's going to take some time before we implement it)?

Mannerly answered 13/3, 2014 at 11:23 Comment(0)
K
5

SubGit synchronizes only branches you've specified in the SubGit config file. By default they are:

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

So if you use another namespace, e.g. refs/heads/nosync/*, branches in it won't be synchronized.

Or you can use refs/heads/* for normal branches (that are out of synchronization) and setup special refs/heads/sync/* namespace for synchronization:

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

Note, that long branch names (like refs/heads/sync/master) don't lead to inconvenience because after cloning such Git repository, you can assign your own local refs/heads/* branches with short names to track branches with long names from one or another namespace. That's why I think this is a good solution for you.

Kafka answered 14/3, 2014 at 14:54 Comment(6)
Actually, I tried yesterday this solution (which reflects the one I already found) and noticed that merge commits are not a problem, meaning they do not cause subgit to synchronize the special branch namespace onto svn. So, this is definitely the solution I was looking for. Thank you!Mannerly
Maybe I'm missing something but in your example code block, shouldn't branches have nosync not sync in there?Effy
The block is correct, refs/heads/* are not mentioned, so they are not synchronized; refs/heads/sync/* are mentioned, so they are synchronized.Kafka
Ah, I understand now. I'd missed the point that in Git you'd be creating branches which are local to Git in refs/heads//* and since it's only bits that are mapped under '/refs/heads/sync` that are tracked relative to SVN, the Git-only branches won't be sync'd with SVN. Seems like a fairly neat solution - thanks!Effy
Do you have an example of creating the refs with short names when cloning the subgit repository?Effy
I don't understand the question, please write to my e-mail (which can be found in my profile) what you mean by "short names". Probably you mean branches like 'master', but they are actually refs/heads/master in Git.Kafka

© 2022 - 2024 — McMap. All rights reserved.