Using Subversion and Git Together


Published on

SubGit is a server-side tool that helps to accomplish Svn to Git migration or Svn/Git synchronization task. This talk describes SubGit pros and cons and compares SubGit with its client-side Git-Svn alternative.

Published in: Technology
1 Comment
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Using Subversion and Git Together

  1. 1. Subversion DayUsing Subversion and Git Together June 14th 2012, Berlin
  2. 2. About Us● TMate Software● We create VCS tools since year 2003● Products at pre-release stage ● SubGit (RC, self-hosting for 6 months) ● HG4J (Beta)● Our mature products: ● SvnKit (1.7.4, 30% of the ASF requests) ● SqlJet (1.1.2)
  3. 3. Subversion and Git● Subversion: ● Mature, well known and widely used ● Centralized ● Manager-friendly● Git: ● Fast growing VCS ● Distributed ● Geek-friendly
  4. 4. Subversion and Git server● Single repository at ● Many repositories shared centralized server ● Forks● All branches and forks are in the same repository ● Delayed commits
  5. 5. Subversion and GitHow is it possible to use both?!
  6. 6. Two ApproachesGit-Svn or SubGit
  7. 7. Git-Svn Approach overviewserver server
  8. 8. Git-Svn Approachclient-side, partisan deployment server User 1 User 2
  9. 9. Git-Svn Approachdouble translation, resulting in data loss server2. pull: 1. push: Svn to Git Git to Svn User 1 User 2
  10. 10. Git-Svn Approach custom non-Git workflow Git-Svn commands: server ● fetch ● dcommit ● rebase ● branch ...User 1
  11. 11. Git-Svn Approach custom non-Git workflowStandard Git push: - local commit - remote commit local state git pull, git push, merge commit created new commits pushed
  12. 12. Git-Svn Approach custom non-Git workflowGit-Svn dcommit: local state git svn dcommit, git svn dcommit, git svn dcommit, requires rebase first (commit) (fetchback, sign)
  13. 13. Git-Svn Approach summary● Client side● Each user needs to translate at least part of the repository● Non-standard workflow● Part of standard Git package, but...● …git-svn is 5000 lines script of perl code
  14. 14. SubGit overview subgitserver
  15. 15. SubGit approach details● Installed into repository● Uses hooks● Translation is performed in the background to minimize overhead
  16. 16. SubGit default installationServer Subversion svn pre-commit hook SubGit translation daemon git pre-receive hook git post-receive hook Git
  17. 17. SubGit Apache configuration example<Location /svn> # DAV Svn SVNParentPath /var/svn/repos Require valid-user AuthType Basic AuthUserFile /var/svn/repos/passwords</Location><Location /git> # ScriptAlias /git/ … … Require valid-user AuthType Basic AuthUserFile /var/svn/repos/passwords</Location>
  18. 18. SubGit asynchronous translation svn subgit git data transfer translation scheduled pre-commitrevision installed revision added to post-commit SubGit translation queue git commit created
  19. 19. SubGit asynchronous translation git subgit svn data transfer translation scheduled pre-receivereferences updated post-receive commit(s) added to SubGit translation queue svn revision created
  20. 20. SubGitasynchronous translation git subgit svn
  21. 21. SubGit summary● Server side● One-time centralized deployment● Reuse of existing infrastructure● Pure Git/Subversion experience● Safe and smooth migration● Commercial quality tool
  22. 22. SubGit safe migrationsubgit
  23. 23. SubGit smooth migrationVCS transparency “Clean cut” Git adoption t migrationVCS transparency SubGit smooth t migration
  24. 24. Subversion<=>Git Translation● Branches and Tags ● References● Deltas ● Trees● Special properties ● Special files● Merge tracking info ● Commit parents
  25. 25. Branches and Tags overview master 1.1.x 1.0.x/trunk/branches/branches/1.0.x/branches/1.1.x/tags/tags/1.0.0 1.0.0--- r10M /branches/1.0.x/file.txt
  26. 26. Branches and Tags mappingtrunk = trunk:refs/heads/masterbranches = branches/*:refs/heads/*tags = tags/*:refs/tags/*shelves = shelves/*:refs/shelves/*
  27. 27. Branches and Tagsmaster Which history line is a trunk? And which is a branch? Heuristics help!
  28. 28. Branches and Tags shelvesmaster Unnamed Git branch /shelves/author[_date] --- r20 M /shelves/alex/file.txt
  29. 29. Branches and Tags attic referencesmaster branch master master attic/ branch
  30. 30. Braches and Tags● From Subversion to Git ● Single Subversion revision might be translated to multiple Git commits● From Git to Subversion ● Heuristics help to detect target branch in complex cases ● /shelves directory is used to store anonymous branches
  31. 31. Deltas and Trees● Subversion revision is a delta: --- r20 A /trunk/file.txt M /trunk/dir/file.txt A /trunk/dir/copy.txt from /trunk/file.txt@r10 D /trunk/dir/old_file.txt● Delta tracks copies● Git commit is always a full file tree
  32. 32. Deltas and Trees● From Subversion to Git ● Relevant part of the delta is applied to the parent commit tree● From Git to Subversion ● Renames and copies are detected at translation time ● Branches and tags creation uses copy operation
  33. 33. Special Properties● properties: ● files: ● svn:ignore ● .gitignore ● svn:eol-style ● .gitattributes ● svn:mime-typefile.txt .gitattributes svn:eol-style=native * text=auto !eol
  34. 34. Special Properties● From Subversion to Git ● svn:ignore; svn:mime-type and svn:eol-style are translated● From Git to Subversion ● .gitignore and relevant values set in .gitattributes are translated
  35. 35. Merge TrackingGit merge commits: In Git merges are tracked by: ● Natural history ● Merge commits parents ● Merge unit is commit
  36. 36. Merge Tracking● Subversion tracks merges by ● Natural history ● Revisions ranges (including cherry-picks)● Merge unit is file or a directory /trunk@r100 svn:mergeinfo=/branches/1.0.x:1-100,105 /trunk/file.txt@r100 svn:mergeinfo=/branches/1.0.x/file.txt:102
  37. 37. Merge Tracking● From Subversion to Git ● Branch-level merges are translated to merge commits● From Git to Subversion ● Merge commits are represented with svn:mergeinfo
  38. 38. Not Yet Translated (in SubGit 1.0)● Empty directories● Arbitrary properties● Revision properties● Externals references
  39. 39. It Works!$ svnadmin create repos....$ subgit install repos$ git clone repos git-clone....$ svn co svn://host/repos wc....
  40. 40. SubGit Target Audience● Managers who listen to their Geeks● Hosting providers● Safe and smooth migration● Java 1.5 or newer is needed● Linux, OS X, Windows Server 2003
  41. 41. On SubGit Availabilty● SubGit 1.0 release: June 2012● SubGit is free for Open Source and Start-Up Projects● Closed-source projects will have to register SubGit (purchase a registration key)● Dedicated technical support for SubGit
  42. 42. Thank you!● SubGit on Web:● SubGit on Twitter: @subgit● Page on Google+ (SubGit)● Blog: ● Using Gerrit with Subversion● Thank you! :)