Introduction to Git-SVN
Total Page:16
File Type:pdf, Size:1020Kb
Introduction to Git-SVN Patrick Burma, Solutions Architect, WANdisco Agenda • Migration of SVN and Git • Tools and Techniques • Git-SVN • Sub-Git • Use Cases • References Integrating Subversion and Git Migration of SVN and Git Overview • Lot’s of existing production Subversion repositories, Git is newer and not as mature but growing rapidly – Need a way to mitigate risk, and keep “golden processes” in place while Git infrastructure matures – Others? • Types of migration – One time convert from one system to another – Continuously push data from one system to another – Sync data back and forth between the two Migration of SVN and Git Challenges • Some good ways to push data from one system to another • No great ways to bidirectional sync • Why? – System architectures too different • What’s the answer – Let’s look at our options and then decide…. • Maybe its best to keep one, the other or both as separate systems Migration of SVN and Git High Level Overview • Subversion system – Revs are based on Changesets – Merges are tracked using metadata (svn:mergeinfo) – Data stored in the FSFS • Git – Based on SHA’s – Different merge algorithms (eg; up-to-date, fast-forward) – Data stored in .git repository format • Terminologies and actions differ – Actions in one that don’t exist in the other • Consider clone, push, pull, propset • Some actions do overlap, here is where integration occurs – Commit, rename, move, branch Migration of SVN and Git Use Cases • Best – One time import, for example importing a Subversion repository into Git • Ok – Single direction, for example pushing Git changes into Subversion • Worst – Continuous bi-directional integration between Subversion and Git Migration of SVN and Git Summary • Git and Subversion don’t directly translate – There is no equivalent git rebase command in Subversion • Differences in system architectures and data storage without a common language to interface between them (eg; SQL) • Troubles if you want to do bi-directional integration because: – Branching and merging won’t translate, without merge tracking you’ll be stuck doing 2-way diffs – At the very least you have to minimize some capabilities of either tools and go to a simple and very linear mainline development approach. – Other issues, such as externals, which there are no solutions for? – Any Gothcha’s? • For imports historical accuracy. Especially around moves/renames/ deletes. Tools and Techniques Tools • Git-SVN – Comes with Git • Sub-Git – Free to download and try, has a cost to use in production • Custom scripts and services • Others – Clearvision – Tailor (dead project) – SSCM (also dead) – More? Tools and Techniques Techniques • Consider a few Git best practices. – Tendency is to have many more Git repositories then Subversion • Scope out mapping options – Repo-to-repo, this would mean one Git repository to one Subversion repository – Project based? Many Git repositories map to a single Subversion repository as projects – Branches, Tags and Trunks. • Common layouts or unique layouts? Tools and Techniques Techniques • Automate with post-commit hooks • Develop new repo generation scripts – Sets config options and points to proper places • Author mapping • Understanding Limitations – Git Rebase – Fast-Forward Merges – Squashed History – Weird Stuff Git-SVN About • Comes with Git • Perl script • Several iterations and improvements Git-SVN Commands • Main git svn commands – Clone – Fetch – Log Git-SVN Examples • Create repositories from test Subversion repository for Git and workspace for SVN git svn clone https://pat-wandisco.googlecode.com/svn/trunk/ pat- wandisco.git --username [email protected] svn checkout https://pat-wandisco.googlecode.com/svn/trunk/ pat- wandisco --username [email protected] --password hH3YV5jc6CP4 • Modify and commit files from Git cd pat-wandisco.git/trunk echo test git commit >> file1.txt git commit –m “Adding my first change to git, my name is” git svn dcommit Git-SVN Examples • Modify files in Subversion cd ../../pat-wandisco/trunk svn up svn log echo test svn commit >> file1.txt svn ci –m “Adding my commit from Subversion” • Add another change from Git cd ../../pat-wandisco.git/trunk git svn fetch git rebase echo second change from git >> file1.txt” it svn dcommit Sub-Git Overview • Builds a Git repo from an SVN repo • Remote Installation – If the repositories are not on the same system • Local Installation – They are on the same box • Config file stores items such as mappings for projects, directories/branches, and authors – Allows for easy re-use/re-run of the syncs • Includes ignores, symlinks, merge tracking, renames, eol settings • Fairly simple to use • Not free beyond trial use Sub-Git Overview Sub-Git Examples • Setup service accounts – Git/Apache/SVN, run them as same user (easiest) • Run subgit configure – subgit configure reponame • Modify configuration file • reponame/conf/Subgit.conf • Run subgit install – subgit install reponame • Modify .git/config settings • Write and implement hooks Use Cases From the Audience • Git is new and growing, but all our infrastructure is built around Subversion • Don’t want to maintain two distinct ALM stacks • Can’t enforce security on Git, but can on Subversion • No Git infrastructure to speak of (some devs are just using it) • Need to collaborate between two or more BU’s, vendors, customers using either Git or Subversion References External Links • http://git-scm.com/book/en/Git-and-Other-Systems-Migrating-to-Git • http://www.drdobbs.com/architecture-and-design/migrating-from-subversion-to-git-and-the/240009175 • http://code.google.com/p/support/wiki/ConvertingSvnToGit • http://thomasrast.ch/git/git-svn-conversion.html • http://subgit.com • http://jaibeermalik.wordpress.com/2013/10/23/svn2git-migrating-repository-from-subversion-to-git/ • http://git-scm.com/book/ch8-1.html • http://maymay.net/blog/2009/02/24/how-to-use-git-svn-as-the-only-subversion-client-youll-need/ • https://git.wiki.kernel.org/index.php/Git-svn Thank You Pat Burma .