I would like to know the recommended way to move our code from a SVN repository to a GIT repository, so that we transition our developers team & start using GIT.
Can we do the transition and keep all the commits done in the SVN repository ?
Also, our team is happy with SVN currently, but, they don't know that branching in GIT is much easier than SVN, where can I find a practical example that proves power of GIT in branching ?
There are many tools such as svn2git available to perform the migration, in this tutorial we will focus on git-svn utility: a Git extension , which can be used to check out a Subversion repository to a local Git repository and then push changes from the local Git repository back to the Subversion repository.
# Clone a repo with standard SVN directory layout (like git clone): git svn clone http://svn.example.com/project --stdlayout --prefix svn/ # Or, if the repo uses a non-standard directory layout: git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ # View all branches and tags you have ...
The git svn clone command transforms the trunk, branches, and tags in your SVN repository into a new Git repository. Depending on the structure of your SVN repo, the command needs to be configured differently.
Eric Raymond (esr) has created reposurgeon, “a command interpreter for performing tricky editing operations on version-control histories.” The tool includes scripts for various purposes, including cleaning up the results of VCS conversions. Check it out from https://gitlab.com/esr/reposurgeon.
As of version 2.0 it includes support for reading SVN dumpfiles for complete and idiomatic translation to Git, Mercurial, etc.; see http://esr.ibiblio.org/?p=4071 for details. Reposurgeon has been used to convert several large projects to Git, including Emacs whose repository, ESR says, “is large, complex in branch structure, and old enough to have begun life as a CVS repo. That last part matters because some of the ugliest translation problems lurking in the back history of Subversion projects are strange Subversion operation sequences (including combinations of branch copy operations) generated by cvs2svn.”
(The git-svn tool included with Git will handle many Subversion repositories, including branches. It’s pretty commonly used, especially by teams that are in the process of doing a conversion, since it allows Git to behave as a Subversion client. But see ESR’s Don’t do svn-to-git repository conversions with git-svn!, where he discusses the drawbacks to git-svn as a conversion tool.)
Regarding your second question, it isn’t branching where the power of Git is so helpful (though Git is at least as powerful as Subversion in this regard); it’s when it comes to merging those branches that Git shines. Read through the Git Community Book, especially the section in chapter 3 titled “Basic Branching and Merging” and the section in chapter 7 titled “Advanced Merging”.
Since there are already lots of people working with git-svn, I'd say it's very much possible. The following command is pretty well known:
git svn clone -s http://svn/repo
According to the manual (verified locally), this will keep the "trunk, tags and branches".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With