Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git-svn: Is there a good branching and merging pattern?

I'm running the git-svn client on my machine. I'd like to have a pattern similar to a standard git branching and merging pattern, wherein you have a development branch which was branched from trunk, and you have several feature or bug-fix branches that have extended from the development branch.

The problem I'm having is that I can't figure out how to make that all work with git-svn. I know that merging is a pain with vanilla subversion and that it's nice with vanilla git, but it's also turning out to be a pain with git-svn.

So.... what is the best practice? How can you branch and merge confidently and easily with git-svn? What is the development practices with it?

I would like to follow this pattern:

* Master
|\
| * Development
| |\
| | * Feature
| | |
| | * a commit to feature
| |\|
| | * merge Development into Feature
| | |
| |/|
| * | merge Feature into Development
 ... etc

Any help would be greatly appreciated!!

EDIT

Just to clarify - each git branch should correspond with an svn branch. This is a team workflow, where team members should be able to work on feature and bug fix branches.

like image 560
Mr Mikkél Avatar asked Nov 12 '22 18:11

Mr Mikkél


1 Answers

In short:

  • branch server side
  • synchronize merge single direction (from trunk to branches/feature)
  • merge back (reintegrate) once for all (this will close the branch)

This my current recommended workflow with svn based on some notes. Words in between < and > are place holders.

Tips:

T1: use the symbols "^/" to refer to your base repository. From anywhere in your project you can list against the repository with:

svn list ^/<repo_path>

T2: to now on which branch you are currently working use

svn info | grep URL

Recommendations:

R1: do not checkout the top project dir (the one containing trunk/ branches/ and tag/) but the trunk dir itself, i.e.:

don't do:

svn checkout <BASE_URL>/svn/<proj>

but do:

svn checkout <BASE_URL>/svn/<proj>/trunk workdir

and use switch.

R2- When branching, always do it server side to avoid copying.

dont'do:

svn cp workdir/trunk workdir/branches/feature

do:

svn cp ^/trunk ^/branches/feature

followed by:

cd <workdir_path>
svn sw ^/branches/feature

R3: only merge (synchronize) from trunk to your branch.

cd <workdir_path>
svn merge ^/trunk

R4: to merge on the other direction (from branch to trunk) use reintegrate merge.

svn up
svn switch ^/trunk
svn merge --reintegrate ^/branches/<feature>
(resolve conflicts and ...)
svn ci

Exception: If you need to cherry-pick a change to the trunk, you may preffer to do it with the --ignore-ancestry (to avoid complication with history)

like image 172
ptitpion Avatar answered Nov 15 '22 06:11

ptitpion