Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git svn and working with private branches?

new git user here. I want to use git, but i'm in an SVN environment. From some books I've read and some simple experimenting, I've hit some troubling pitfalls and am hoping to get clarification on how to get starting without my colleagues wanting to kill me.

I want my workflow to be:

  • a master git branch that stays in step with svn's trunk.

  • local git branches that i do my feature and bug work in.

  • I want to frequently bring the feature branches up to date with master.

  • When i'm ready I want to merge a feature branch in with master and commit that back to svn.

Is this a typical workflow?

Initially I was using git merge to merge my master branch and feature branches. This led to all kinds of conflicts and problems. I later read to avoid using git merge alltogether and stick with git rebase. Would the following git commands, then, be correct?

  • git svn rebase (to pull down latest changes to master)
  • git checkout -b myAwesomeFeature (to make a feature branch to work on)
  • ... do some work, make commits to my feature branch
  • <<< TIME GOES BY >>>
  • git checkout master
  • git svn rebase (to pull down new stuff)
  • git checkout myAwesomeFeature
  • git rebase master ( to get svn trunk's stuff into my feature branch)
  • <<< READY TO PUSH MY FEATURE BRANCH >>>
  • git checkout master
  • git rebase myAwesomeFeature (to fast forward masters head to get my feature stuff in)
  • git svn dcommit (to finally publish)

Any advice or suggestions to help an aspiring git user live in an svn world would be really appreciated. Thanks

like image 576
D.C. Avatar asked Nov 04 '22 13:11

D.C.


1 Answers

Your workflow is about the same I have. It is good enough if you are only committing to the svn trunk. It gets complicated when you commit to multiple svn branches where rebase not only merges the contents, but also changes the pointed-to svn branch, in which case, you can only git cherry-pick when you need commits into one svn branch targeting git branch in another, as discussed here: Overcome git svn caveats

It is also worth understanding that SVN's inability to handle non-linear history and that git merge can't be used with it: git svn workflow - feature branches and merge

like image 100
lprsd Avatar answered Nov 13 '22 23:11

lprsd