Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will this git-svn workflow work?

Tags:

git

git-svn

I'm experimenting with git-svn, and am trying to come up with a relatively non error-prone workflow. I think the following should work, and is pretty simple, but I've seen people using far more complicated workflows, so I want to see why.

  1. (master) $ git svn init <path>
  2. (master) $ git svn fetch
  3. (master) $ git svn rebase
  4. (master) $ git checkout -b topic-branch
  5. (topic-branch) $ # HACK HACK COMMIT HACK HACK HACK COMMIT HACK COMMIT
  6. (topic-branch) $ git checkout master
  7. (master) $ git merge topic-branch -- this is a fast-forward merge, so no merge commit
  8. (master) $ git svn rebase
  9. (master) $ # fix conflicts
  10. (master) $ git svn dcommit
  11. GOTO 4
like image 740
davidtbernal Avatar asked Dec 06 '10 21:12

davidtbernal


People also ask

Can you use Git and SVN together?

git-svn is a specialized tool for Git users to interact with Git repositories. It works by providing a Git frontend to an SVN backend. With git-svn, you use Git commands on the local repository, so it's just like using normal Git. However, behind the scenes, the relevant SVN commands are sent to the server.

How does Git SVN work?

git svn is a git command that allows using git to interact with Subversion repositories. git svn is part of git, meaning that is NOT a plugin but actually bundled with your git installation. SourceTree also happens to support this command so you can use it with your usual workflow.

Should I use SVN or Git?

SVN is better than Git for architecture performance, binary files, and usability. And it may be better for access control and auditability, based on your needs.

What is difference between SVN and Git?

The difference between Git and SVN version control systems is that Git is a distributed version control system, whereas SVN is a centralized version control system. Git uses multiple repositories including a centralized repository and server, as well as some local repositories.


2 Answers

Yes, that's essentially what I do when working with Subversion repositories. The key to the simplicity of this is to keep the Git branches local and not try to map them to Subversion branches at all.

I just noticed that you linked directly to my answer in that other question. So perhaps I should explain more. :)

I sometimes do the conflict resolution in the topic branch if I expect some conflict work. Otherwise, if I don't expect many conflicts, I might merge to master first before doing the git svn rebase. It doesn't matter much.

The key point is that Git is so flexible that the minimum workflow is very simple. You've added a topic branch to that; I've added rebasing on the topic branch.

like image 134
Greg Hewgill Avatar answered Nov 15 '22 19:11

Greg Hewgill


From my brief experience I've made minor adjustments to your workflow and added comments:

  1. (master) $ git svn init <path> (or (master) git svn clone <url>)
  2. (master) $ git svn fetch
  3. (master) $ git svn rebase (begin loop, resolve conflicts)
  4. (master) $ git checkout -B topic-branch (careful before doing this)
  5. (topic-branch) ## HACK HACK COMMIT HACK COMMIT (use 3rd party)
  6. (topic-branch) $ git checkout master
  7. (master) $ git rebase topic-branch (resolve conflicts)
  8. (master) $ git svn rebase (resolve conflicts, if any)
  9. (master) $ git svn dcommit (careful reading here)
  10. GOTO 3 (or 4 if no need to rebase again)

I'm using master branch just for integration with SVN and doing all work on topic-branch, just like I believe you were. I hope this makes more sense, since I couldn't use your workflow the way it was even if it was basically what I wanted - evidently! :-)

More details on the adjustments that were made:

  • Attention to capital -B on step 4, it will reset the topic-branch so it's always new from current SVN. without it the loop would break giving an error "branch already exists".
  • Step 7 using rebase rather than merge. yes, it will probably be a fast-forward merge, but it's better safe than sorry. picture if something is done between steps 6 and 7.
  • Loop to 3 instead of 4. Also, just to play on the safe side. Seems like using svn rebase never is an abuse and since it's always done on master there's always branches as backup.
like image 20
cregox Avatar answered Nov 15 '22 20:11

cregox