Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep svn repository in sync with git one

my team mate and I are struggling to get our svn repository in sync with our git one. We are working on a project and we are requested to share our code on an svn repository (hosted by the assembla.com site). Since we are used to version control our code with git, we decided to make good use of the git svn feature git provides. To share all our work and keep it divided in the right branches, we have a remote repository for git too (bitbucket).

So far all our work committed with git haven't gave us problems, but when it comes to sync the svn repository errors after errors are coming up.

I followed this answer Pushing an existing git repository to SVN to connect the svn repository to the git one, but after a few merges and commit, i'm getting errors and i'm not able to dcommit the changes anymore.

Right now i have a branch which is the copy of svn/trunk

$ git checkout -b assembla_copy -t svn/trunk
  Branch assembla_copy set up to track local ref refs/remotes/svn/trunk.
  Switched to a new branch 'assembla_copy'

$ git svn rebase svn/trunk
Current branch assembla_copy is up to date.

To sync it with my master branch i both tried to

git merge master

and

git rebase master

But while git rebase master start to apply all the changes since the first commit and giving lots and lots of conflicts(when i already have this changes in the svn/trunk instead, since in some way i managed to push some changes to the online repository; we are ar r46 at the moment ), git merge master goes fine but then when i dcommit, all the changes are summed up in only one commit where it states that "Merge branch 'master' into assembla_copy", while i would prefer that it would commit all the separate commits (like it did at the beginning..).

If i dcommit from the master branch, all the commits are separated, but then the master branch is rebased, so all the branches that have a master commit as parent shows as separated form the master branch..

Could you explain to me the right workflow to have an svn repository that mirrors a git repository, where all the work is done (the svn one is just a copy)? Could you use just standard git commands and not intricate bash scripts as i have seen in some answers while searching for a solution in the last week?

Thank you!

like image 411
Makers_F Avatar asked May 15 '13 13:05

Makers_F


People also ask

Can I use Git and SVN at the same time?

No interaction between them. Just ignore the . git folder for SVN and the . svn folder for Git and you should be fine.

Does Tortoisesvn work with Git?

It totally works. you have check the use svn repository and possibly specify username so it prompts for password.... but it works.


1 Answers

I'm using the following workflow with the goal of having a local git repo as some kind of fancy svn client for a remote SVN repository.

  • initialize the repository using git svn clone .... This leaves the master branch follwing the SVN trunk - this should be svn/trunk in your case.
  • create a local "baseline" branch from the master: git checkout -b local. This would be master in your case.
  • Start working on a feature branch of local - git checkout -b feature
  • when I'm ready to commit to the remote SVN:
    • git checkout master
    • git svn rebase - Fetch SVN updates
    • if there are any updates, I merge them into local
    • git rebase --onto master local feature - Changes made in the feature branch compared to local baseline are applied to master branch
    • Merge feature branch into master: git checkout master, git merge feature
    • git svn dcommit - Commit changes to SVN
    • Merge new feature into local baseline: git checkout local, git merge master - Same as if someone else has committed something to SVN.

Hope this helps.

like image 132
SKempken Avatar answered Sep 21 '22 11:09

SKempken