43 Syncing with Subversion

One of Git’s key advantages over other DVCSs early on was its ability to communicate with Subversion through git-svn. Though other DVCSs now have integration with Subversion to varying degrees, Git still leads the pack.

git-svn is installed by default on most systems, but on Ubuntu and other Linux-based systems that break up software into individual packages. you do need to install it separately (see Task 1, Installing Git).

You can clone a Subversion repository with a standard layout[19] by using git svn clone -s and providing Git with the repository URL. You can use --trunk, --tags, and --branches to provide Git with a custom location for your trunk, tags, and branches.

Creating a clone is all you need to do if you’re migrating to Git from Subversion, but Git can continue to talk to Subversion if you’re not making the switch.

There is no direct git svn update available on Subversion clones. Instead, you use git svn rebase to update your local branch with the upstream changes in Subversion. This fetches the changes from Subversion and then rebases your local branch against the upstream changes.

Remember, using rebasing commits (whether with git rebase or through git svn rebase) comes at a potential cost. git-svn requires a rebase to keep track of which commits are in Subversion and which are only in Git. Because of this, it’s not a good idea to share changes directly via Git clones of Subversion repositories. Use Subversion for sharing changes.

You can push changes back upstream to a Subversion repository with git svn dcommit. You can add the -n parameter if you want to see what commits will be sent upstream without actually sending them.

The output from any of the git svn commands could take up several pages of output, so I haven’t included any output here.

What To Do...
  • Create a Git clone of a standard Subversion repository.
     
    prompt>​ git svn clone -s svn://example.com/repo
  • Perform the equivalent of an svn update.
     
    prompt>​ git svn rebase
  • Push changes back to upstream Subversion repository.
     
    prompt>​ git svn dcommit

    Or, to see what commits would be sent back upstream, use this:

     
    prompt>​ git svn dcommit -n

Related Tasks

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.195.225