Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN / Git / Bash

Tags:

git

bash

svn

ubuntu

I am working on a project with a team. They use SVN, but I prefer git. While I could do this more easily by simply getting better at SVN - I'd prefer to make my life complicated and use Git.

Here is their setup:

  ~/www(svn)
   |       \
trunk(svn)  mybranch(svn)

I would like to have

/srv/git/www 

with branches trunk and mybranch

when I do git pull inside the /srv/git/www while on the trunk branch I would just love it if a script ran svn update on ~/www/trunk and update the git branch with any svn commits (so that the git history and commit messages matches the svn and commit messages)

it would do the same behavior on git pull on the git mybranch branch

My workflow would then be

git checkout trunk
git pull
git checkout mybranch
git rebase trunk

do some work

(if trunk hasn't been updated since I pulled on it):

git commit 
git push
git checkout trunk
git merge mybranch
git push

I would love it if a git hook would then trigger svn commit whenever code is pushed to either of those branches.

Please offer any advice. I initially tried just using SVN - but am so frustrated by it locking, and having to re-checkout whenever a merge goes bad that I'm super annoyed with SVN.

If anyone has a better model for doing this, please tell me. Otherwise it would be outstanding if you could point me in the direction of how to do it with git! I know there is a git svn command, but I don't trust it - I was hoping the above is safer (albeit it seems a little insane to me.)

Thank you!

like image 570
Alex Waters Avatar asked Jan 03 '13 22:01

Alex Waters


1 Answers

You've described how SubGit works. Since 2.0 it allows a bi-directional translation between Git and SVN using pre-receive Git hook (that is executed on 'git push'). To do that run on your machine

$ subgit configure --svn-url <URL_of_repository_root> repo.git
$ #adjust repo.git/subgit/{config,passwd,authors.txt} to set auth options, branches to translate and SVN<->Git authors mapping
$ subgit install repo.git

Then clone repo.git (even if it's on the same machine just to make 'pre-receive' hook work)

$ git clone repo.git myproject
$ cd myproject
$ #do something with master
$ git push origin master

Every new commit reachable from 'master' will be translated to a commit in SVN. By default the same is true for other branches.

like image 124
Dmitry Pavlenko Avatar answered Oct 02 '22 03:10

Dmitry Pavlenko