<p>I read the Git manual, FAQ, Git - SVN crash course, etc. and they all explain this and that, but nowhere can you find a simple instruction like:</p>

<p>SVN repository in: <code>svn://myserver/path/to/svn/repos</code></p>

<p>Git repository in: <code>git://myserver/path/to/git/repos</code></p>

<pre><code>git-do-the-magic-svn-import-with-history \
svn://myserver/path/to/svn/repos \
git://myserver/path/to/git/repos
</code></pre>

<p>I don't expect it to be that simple, and I don't expect it to be a single command. But I do expect it not to try to explain anything - just to say what steps to take given this example.</p>

[{'answer_id': 79178, 'author': 'jfm3', 'author_id': 11138, 'author_profile': 'https://Stackoverflow.com/users/11138', 'pm_score': 10, 'selected': True, 'text': '<p>Magic:</p>\n\n<pre><code>$ git svn clone http://svn/repo/here/trunk\n</code></pre>\n\n<p>Git and SVN operate very differently.  You need to learn Git, and if you want to track changes from SVN upstream, you need to learn <code>git-svn</code>.  The <code>git-svn</code> <a href="https://git-scm.com/docs/git-svn" rel="noreferrer">main page has a good examples section</a>:</p>\n\n<pre><code>$ git svn --help\n</code></pre>\n'}, {'answer_id': 79188, 'author': 'Eugene Yokota', 'author_id': 3827, 'author_profile': 'https://Stackoverflow.com/users/3827', 'pm_score': 8, 'selected': False, 'text': '<p><a href="https://web.archive.org/web/20160314221641/https://jonmaddox.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/" rel="noreferrer">Cleanly Migrate Your Subversion Repository To a Git Repository</a>. First you have to create a file that maps your Subversion commit author names to Git commiters, say <code>~/authors.txt</code>:</p>\n\n<pre><code>jmaddox = Jon Maddox &lt;jon@gmail.com&gt;\nbigpappa = Brian Biggs &lt;bigpappa@gmail.com&gt;\n</code></pre>\n\n<p>Then you can download the Subversion data into a Git repository:</p>\n\n<pre><code>mkdir repo &amp;&amp; cd repo\ngit svn init http://subversion/repo --no-metadata\ngit config svn.authorsfile ~/authors.txt\ngit svn fetch\n</code></pre>\n\n<p>If you’re on a Mac, you can get <code>git-svn</code> from MacPorts by installing <code>git-core +svn</code>.</p>\n\n<p>If your subversion repository is on the same machine as your desired git repository,\nthen you can use this syntax for the init step, otherwise all the same:</p>\n\n<pre><code>git svn init file:///home/user/repoName --no-metadata\n</code></pre>\n'}, {'answer_id': 85456, 'author': 'EfForEffort', 'author_id': 14113, 'author_profile': 'https://Stackoverflow.com/users/14113', 'pm_score': 4, 'selected': False, 'text': '<p>See the official <a href="http://git-scm.com/docs/git-svn" rel="noreferrer">git-svn manpage</a>.  In particular, look under "Basic Examples":</p>\n\n<blockquote>\n  <p>Tracking and contributing to an entire Subversion-managed project (complete\n      with a trunk, tags and branches):</p>\n</blockquote>\n\n<pre><code># Clone a repo (like git clone):\n    git svn clone http://svn.foo.org/project -T trunk -b branches -t tags\n</code></pre>\n'}, {'answer_id': 86094, 'author': 'webmat', 'author_id': 6349, 'author_profile': 'https://Stackoverflow.com/users/6349', 'pm_score': 6, 'selected': False, 'text': '<p>I suggest getting comfortable with Git before trying to use git-svn constantly, i.e. keeping SVN as the centralized repo and using Git locally.</p>\n<p>However, for a simple migration with all the history, here are the few simple steps:</p>\n<p>Initialize the local repo:</p>\n<pre><code>mkdir project\ncd project\ngit svn init http://svn.url\n</code></pre>\n<p>Mark how far back you want to start importing revisions:</p>\n<pre><code>git svn fetch -r42\n</code></pre>\n<p>(or just &quot;git svn fetch&quot; for all revs)</p>\n<p>Actually, fetch everything since then:</p>\n<pre><code>git svn rebase\n</code></pre>\n<p>You can check the result of the import with Gitk. I\'m not sure if this works on Windows, it works on OSX and Linux:</p>\n<pre><code>gitk\n</code></pre>\n<p>When you\'ve got your SVN repo cloned locally, you may want to push it to a centralized Git repo for easier collaboration.</p>\n<p>First create your empty remote repo (maybe on <a href="http://github.com" rel="nofollow noreferrer">GitHub</a>?):</p>\n<pre><code>git remote add origin git@github.com:user/project-name.git\n</code></pre>\n<p>Then, optionally sync your main branch so the pull operation will automatically merge the remote master with your local master when both contain new stuff:</p>\n<pre><code>git config branch.master.remote origin\ngit config branch.master.merge refs/heads/master\n</code></pre>\n<p>After that, you may be interested in trying out my very own <code>git_remote_branch</code> tool, which helps to deal with remote branches:</p>\n<p>First explanatory post: &quot;<a href="http://programblings.com/2008/06/23/git-remote-branches/" rel="nofollow noreferrer">Git remote branches</a>&quot;</p>\n<p>Follow-up for the most recent version: &quot;<a href="http://programblings.com/2008/08/06/time-to-git-collaborating-with-git_remote_branch/" rel="nofollow noreferrer">Time to git collaborating with git_remote_branch</a>&quot;</p>\n'}, {'answer_id': 110020, 'author': 'webmat', 'author_id': 6349, 'author_profile': 'https://Stackoverflow.com/users/6349', 'pm_score': 3, 'selected': False, 'text': '<p>GitHub now has a feature to <a href="http://github.com/blog/156-subversion-importing" rel="noreferrer">import from an SVN repository</a>. I never tried it, though.</p>\n'}, {'answer_id': 139428, 'author': 'Gregg Lind', 'author_id': 15842, 'author_profile': 'https://Stackoverflow.com/users/15842', 'pm_score': 2, 'selected': False, 'text': '<p>As another aside, the git-stash command is a godsend when trying to git with git-svn dcommits.</p>\n\n<p>A typical process:</p>\n\n<ol>\n<li>set up git repo</li>\n<li>do some work on different files</li>\n<li>decide to check some of the work in, using git</li>\n<li>decide to <code>svn-dcommit</code></li>\n<li>get the dreaded "cannot commit with a dirty index" error.  </li>\n</ol>\n\n<p>The solution (requires git 1.5.3+):  </p>\n\n<pre><code>git stash; git svn dcommit ; git stash apply\n</code></pre>\n'}, {'answer_id': 3787897, 'author': 'burkestar', 'author_id': 391678, 'author_profile': 'https://Stackoverflow.com/users/391678', 'pm_score': 0, 'selected': False, 'text': '<p><em><a href="http://www.viget.com/extend/effectively-using-git-with-subversion/" rel="nofollow">Effectively using Git with Subversion</a></em> is a gentle introduction to git-svn. For existing SVN repositories, git-svn makes this super easy. If you\'re starting a new repository, it\'s vastly easier to first create an empty SVN repository and then import using git-svn than it is going in the opposite direction. Creating a new Git repository then importing into SVN can be done, but it is a bit painful, especially if you\'re new to Git and hope to preserve the commit history.</p>\n'}, {'answer_id': 3972103, 'author': 'cmcginty', 'author_id': 64313, 'author_profile': 'https://Stackoverflow.com/users/64313', 'pm_score': 11, 'selected': False, 'text': '<p>Create a users file (i.e. <code>users.txt</code>) for mapping SVN users to Git:</p>\n<pre><code>user1 = First Last Name &lt;email@address.com&gt;\nuser2 = First Last Name &lt;email@address.com&gt;\n...\n</code></pre>\n<p>You can use this one-liner to build a template from your existing SVN repository:</p>\n<pre><code>svn log -q | awk -F \'|\' \'/^r/ {gsub(/ /, &quot;&quot;, $2); sub(&quot; $&quot;, &quot;&quot;, $2); print $2&quot; = &quot;$2&quot; &lt;&quot;$2&quot;&gt;&quot;}\' | sort -u &gt; users.txt\n</code></pre>\n<p>SVN will stop if it finds a missing SVN user, not in the file. But after that, you can update the file and pick up where you left off.</p>\n<p>Now pull the SVN data from the repository:</p>\n<pre><code>git svn clone --stdlayout --no-metadata --authors-file=users.txt svn://hostname/path dest_dir-tmp\n</code></pre>\n<p>This command will create a new Git repository in <code>dest_dir-tmp</code> and start pulling the SVN repository. Note that the &quot;--stdlayout&quot; flag implies you have the common &quot;trunk/, branches/, tags/&quot; SVN layout. If your layout differs, become familiar with <code>--tags</code>, <code>--branches</code>, <code>--trunk</code> options (in general <code>git svn help</code>).</p>\n<p>All common protocols are allowed: <code>svn://</code>, <code>http://</code>, <code>https://</code>. The URL should target the base repository, something like <a href="http://svn.mycompany.com/myrepo/repository" rel="noreferrer">http://svn.mycompany.com/myrepo/repository</a>. The URL string must <strong>not</strong> include <code>/trunk</code>, <code>/tag</code> or <code>/branches</code>.</p>\n<p>Note that after executing this command it very often looks like the operation is &quot;hanging/frozen&quot;, and it\'s quite normal that it can be stuck for a long time after initializing the new repository. Eventually, you will then see log messages which indicate that it\'s migrating.</p>\n<p>Also note that if you omit the <code>--no-metadata</code> flag, Git will append information about the corresponding SVN revision to the commit message (i.e. <code>git-svn-id: svn://svn.mycompany.com/myrepo/&lt;branchname/trunk&gt;@&lt;RevisionNumber&gt; &lt;Repository UUID&gt;</code>)</p>\n<p>If a user name is not found, update your <code>users.txt</code> file then:</p>\n<pre><code>cd dest_dir-tmp\ngit svn fetch\n</code></pre>\n<p>You might have to repeat that last command several times, if you have a large project until all of the Subversion commits have been fetched:</p>\n<pre><code>git svn fetch\n</code></pre>\n<p>When completed, Git will checkout the SVN <code>trunk</code> into a new branch. Any other branches are set up as remotes. You can view the other SVN branches with:</p>\n<pre><code>git branch -r\n</code></pre>\n<p>If you want to keep other remote branches in your repository, you want to create a local branch for each one manually.  (Skip trunk/master.)  If you don\'t do this, the branches won\'t get cloned in the final step.</p>\n<pre><code>git checkout -b local_branch remote_branch\n# It\'s OK if local_branch and remote_branch are the same names\n</code></pre>\n<p>Tags are imported as branches. You have to create a local branch, make a tag and delete the branch to have them as tags in Git. To do it with tag &quot;v1&quot;:</p>\n<pre><code>git checkout -b tag_v1 remotes/tags/v1\ngit checkout master\ngit tag v1 tag_v1\ngit branch -D tag_v1\n</code></pre>\n<p>Clone your GIT-SVN repository into a clean Git repository:</p>\n<pre><code>git clone dest_dir-tmp dest_dir\nrm -rf dest_dir-tmp\ncd dest_dir\n</code></pre>\n<p>The local branches that you created earlier from remote branches will only have been copied as remote branches into the newly cloned repository. (Skip trunk/master.) For each branch you want to keep:</p>\n<pre><code>git checkout -b local_branch origin/remote_branch\n</code></pre>\n<p>Finally, remove the remote from your clean Git repository that points to the now-deleted temporary repository:</p>\n<pre><code>git remote rm origin\n</code></pre>\n'}, {'answer_id': 4860157, 'author': 'Thiago Leão Moreira', 'author_id': 141639, 'author_profile': 'https://Stackoverflow.com/users/141639', 'pm_score': 6, 'selected': False, 'text': '<p>I used the <a href="https://github.com/nirvdrum/svn2git" rel="noreferrer">svn2git script</a> and works like a charm.</p>\n'}, {'answer_id': 4974152, 'author': 'kdahlhaus', 'author_id': 164133, 'author_profile': 'https://Stackoverflow.com/users/164133', 'pm_score': 4, 'selected': False, 'text': '<p>Pro Git 8.2 explains it:\n<a href="http://git-scm.com/book/en/Git-and-Other-Systems-Migrating-to-Git" rel="noreferrer">http://git-scm.com/book/en/Git-and-Other-Systems-Migrating-to-Git</a></p>\n'}, {'answer_id': 5385391, 'author': 'ripper234', 'author_id': 11236, 'author_profile': 'https://Stackoverflow.com/users/11236', 'pm_score': 2, 'selected': False, 'text': '<p>I highly recommend this <a href="http://www.tfnico.com/presentations/git-and-subversion" rel="nofollow">short series of screencasts</a> I just discovered. The author walks you through the basic operations, and showcases some more advanced usages.</p>\n'}, {'answer_id': 8262076, 'author': 'Alexander Kitaev', 'author_id': 351457, 'author_profile': 'https://Stackoverflow.com/users/351457', 'pm_score': 5, 'selected': False, 'text': '<p>There is a new solution for smooth migration from Subversion to Git (or for using both simultaneously): <a href="http://subgit.com/" rel="nofollow noreferrer">SubGit</a>. </p>\n\n<p>I\'m working on this project myself. We use SubGit in our repositories - some of my teammates use Git and some Subversion and so far it works very well.</p>\n\n<p>To migrate from Subversion to Git with SubGit you need to run:</p>\n\n<pre><code>$ subgit install svn_repos\n...\nTRANSLATION SUCCESSFUL \n</code></pre>\n\n<p>After that you\'ll get Git repository in svn_repos/.git and may clone it, or just continue to use Subversion and this new Git repository together: SubGit will make sure that both are always kept in sync. </p>\n\n<p>In case your Subversion repository contains multiple projects, then multiple Git repositories will be created in svn_repos/git directory. To customize translation before running it do the following:</p>\n\n<pre><code>$ subgit configure svn_repos\n$ edit svn_repos/conf/subgit.conf (change mapping, add authors mapping, etc)\n$ subgit install svn_repos\n</code></pre>\n\n<p>With <a href="http://subgit.com/" rel="nofollow noreferrer">SubGit</a> you may migrate to pure Git (not git-svn) and start using it while still keeping Subversion as long as you need it (for your already configured build tools, for instance).</p>\n\n<p>Hope this helps!</p>\n'}, {'answer_id': 9316931, 'author': 'Jason Huntley', 'author_id': 1214542, 'author_profile': 'https://Stackoverflow.com/users/1214542', 'pm_score': 2, 'selected': False, 'text': '<p>I just wanted to add my contribution to the Git community. I wrote a simple bash script which automates the full import. Unlike other migration tools, this tool relies on native git instead of jGit. This tool also supports repositories with a large revision history and or large blobs. It\'s available via github:</p>\n\n<p><a href="https://github.com/onepremise/SGMS" rel="nofollow">https://github.com/onepremise/SGMS</a></p>\n\n<p>This script will convert projects stored in SVN with the following format:</p>\n\n<pre><code>/trunk\n  /Project1\n  /Project2\n/branches\n     /Project1\n     /Project2\n/tags\n /Project1\n /Project2\n</code></pre>\n\n<p>This scheme is also popular and supported as well:</p>\n\n<pre><code>/Project1\n     /trunk\n     /branches\n     /tags\n/Project2\n     /trunk\n     /branches\n     /tags\n</code></pre>\n\n<p>Each project will get synchronized over by project name:</p>\n\n<pre><code>Ex: ./migration https://svnurl.com/basepath project1\n</code></pre>\n\n<p>If you wish to convert the full repo over, use the following syntax:</p>\n\n<pre><code>Ex: ./migration https://svnurl.com/basepath .\n</code></pre>\n'}, {'answer_id': 16074080, 'author': 'CAD bloke', 'author_id': 492, 'author_profile': 'https://Stackoverflow.com/users/492', 'pm_score': 3, 'selected': False, 'text': '<p>TortoiseGit does this. see this blog post: <a href="http://jimmykeen.net/articles/03-nov-2012/how-migrate-from-svn-to-git-windows-using-tortoise-clients" rel="noreferrer">http://jimmykeen.net/articles/03-nov-2012/how-migrate-from-svn-to-git-windows-using-tortoise-clients</a></p>\n\n<p>Yeah, I know answering with links isn\'t splendid but it\'s a solution, eh?</p>\n'}, {'answer_id': 19001024, 'author': 'thoutbeckers', 'author_id': 2338613, 'author_profile': 'https://Stackoverflow.com/users/2338613', 'pm_score': 3, 'selected': False, 'text': '<p>A somewhat extended answer using just git, SVN, and bash. It includes steps for SVN repositories that do not use the conventional layout with a trunk/branches/tags directory layout (SVN does absolutely nothing to enforce this kind of layout).</p>\n\n<p>First use this bash script to scan your SVN repo for the different people who contributed and to generate a template for a mapping file:</p>\n\n<pre><code>#!/usr/bin/env bash\nauthors=$(svn log -q | grep -e \'^r\' | awk \'BEGIN { FS = "|" } ; { print $2 }\' | sort | uniq)\nfor author in ${authors}; do\n  echo "${author} = NAME &lt;USER@DOMAIN&gt;";\ndone\n</code></pre>\n\n<p>Use this to create an <code>authors</code> file where you map svn usernames to usernames and email as set by your developers using <a href="https://www.kernel.org/pub/software/scm/git/docs/git-config.html" rel="nofollow"><code>git config</code></a> properties <code>user.name</code> and <code>user.email</code> (note that for a service like GitHub only having a matching email is enough).</p>\n\n<p>Then have <a href="https://www.kernel.org/pub/software/scm/git/docs/git-svn.html" rel="nofollow"><code>git svn</code></a> clone the svn repository to a git repository, telling it about the mapping:</p>\n\n<p><code>git svn clone --authors-file=authors --stdlayout svn://example.org/Folder/projectroot</code></p>\n\n<p>This can take incredibly long, since git svn will individually check out every revision for every tag or branch that exists. (note that tags in SVN are just really branches, so they end up as such in Git). You can speed this up by removing old tags and branches in SVN you don\'t need. </p>\n\n<p>Running this on a server in the same network or on the same server can also really speed this up. Also, if for some reason this process gets interrupted  you <em>can</em> resume it using</p>\n\n<p><code>git svn rebase --continue</code></p>\n\n<p>In a lot of cases you\'re done here. But if your SVN repo has an unconventional layout where you simply have a directory in SVN you want to put in a git branch you can do some extra steps.</p>\n\n<p>The simplest is to just make a new SVN repo on your server that does follow convention and use <code>svn copy</code> to put your directory in trunk or a branch. This might be the only way if your directory is all the way at the root of the repo, when I last tried this <code>git svn</code> simply refused to do a checkout.</p>\n\n<p>You can also do this using git. For <code>git svn clone</code> simply use the directory you want to to put in a git branch.</p>\n\n<p>After run</p>\n\n<pre><code>git branch --set-upstream master git-svn\ngit svn rebase\n</code></pre>\n\n<p>Note that this required Git 1.7 or higher.</p>\n'}, {'answer_id': 19814186, 'author': 'NateS', 'author_id': 187883, 'author_profile': 'https://Stackoverflow.com/users/187883', 'pm_score': 2, 'selected': False, 'text': '<p>Here is a simple shell script with no dependencies that will convert one or more SVN repositories to git and push them to GitHub.</p>\n\n<p><a href="https://gist.github.com/NathanSweet/7327535" rel="nofollow">https://gist.github.com/NathanSweet/7327535</a></p>\n\n<p>In about 30 lines of script it: clones using git SVN, creates a .gitignore file from SVN::ignore properties, pushes into a bare git repository, renames SVN trunk to master, converts SVN tags to git tags, and pushes it to GitHub while preserving the tags.</p>\n\n<p>I went thru a lot of pain to move a dozen SVN repositories from Google Code to GitHub. It didn\'t help that I used Windows. Ruby was all kinds of broken on my old Debian box and getting it working on Windows was a joke. Other solutions failed to work with Cygwin paths. Even once I got something working, I couldn\'t figure out how to get the tags to show up on GitHub (the secret is --follow-tags).</p>\n\n<p>In the end I cobbled together two short and simple scripts, linked above, and it works great. The solution does not need to be any more complicated than that!</p>\n'}, {'answer_id': 22380906, 'author': 'Andrew B', 'author_id': 329028, 'author_profile': 'https://Stackoverflow.com/users/329028', 'pm_score': 3, 'selected': False, 'text': '<p>This guide on atlassian\'s website is one of the best I have found:</p>\n\n<p><a href="https://www.atlassian.com/git/migration" rel="noreferrer">https://www.atlassian.com/git/migration</a></p>\n\n<p>This tool - <a href="https://bitbucket.org/atlassian/svn-migration-scripts" rel="noreferrer">https://bitbucket.org/atlassian/svn-migration-scripts</a> - is also really useful for generating your authors.txt among other things.</p>\n'}, {'answer_id': 24255861, 'author': 'Craig Myles', 'author_id': 373406, 'author_profile': 'https://Stackoverflow.com/users/373406', 'pm_score': 2, 'selected': False, 'text': '<p>If you are using SourceTree you can do this directly from the app. Goto File -> New/Clone then do the following: </p>\n\n<ol>\n<li>Enter the remote SVN URL as the "Source Path / URL".</li>\n<li>Enter your credentials when prompted.</li>\n<li>Enter the local folder location as the "Destination path".  </li>\n<li>Give it a name. </li>\n<li>In the advanced options select "Git" from the dropdown in "Create local\nrepository of type".</li>\n<li>You can optionally specify a revision to clone from.</li>\n<li>Hit Clone.</li>\n</ol>\n\n<p>Open the repo in SourceTree and you\'ll see your commit messages have been migrated too.</p>\n\n<p>Now go to Repository -> Repository Settings and add the new remote repo details. Delete the SVN remote if you wish (I did this through the "Edit Config File" option.</p>\n\n<p>Push the code to the new remote repo when you are ready and code freely.</p>\n'}, {'answer_id': 24879012, 'author': 'Valarpirai', 'author_id': 3863121, 'author_profile': 'https://Stackoverflow.com/users/3863121', 'pm_score': 3, 'selected': False, 'text': '<p>You have to Install</p>\n\n<pre><code>git\ngit-svn\n</code></pre>\n\n<p>Copied from this link <a href="http://john.albin.net/git/convert-subversion-to-git" rel="noreferrer">http://john.albin.net/git/convert-subversion-to-git</a>.</p>\n\n<p><strong>1. Retrieve a list of all Subversion committers</strong></p>\n\n<p>Subversion simply lists the username for each commit. Git’s commits have much richer data, but at its simplest, the commit author needs to have a name and email listed. By default the git-svn tool will just list the SVN username in both the author and email fields. But with a little bit of work, you can create a list of all SVN users and what their corresponding Git name and emails are. This list can be used by git-svn to transform plain svn usernames into proper Git committers.</p>\n\n<p>From the root of your local Subversion checkout, run this command:</p>\n\n<pre><code>svn log -q | awk -F \'|\' \'/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" &lt;"$2"&gt;"}\' | sort -u &gt; authors-transform.txt\n</code></pre>\n\n<p>That will grab all the log messages, pluck out the usernames, eliminate any duplicate usernames, sort the usernames and place them into a “authors-transform.txt” file. Now edit each line in the file. For example, convert:</p>\n\n<pre><code>jwilkins = jwilkins &lt;jwilkins&gt;\n</code></pre>\n\n<p>into this:</p>\n\n<pre><code>jwilkins = John Albin Wilkins &lt;johnalbin@example.com&gt;\n</code></pre>\n\n<p><strong>2. Clone the Subversion repository using git-svn</strong></p>\n\n<pre><code>git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp\n</code></pre>\n\n<p>This will do the standard git-svn transformation (using the authors-transform.txt file you created in step 1) and place the git repository in the “~/temp” folder inside your home directory.</p>\n\n<p><strong>3. Convert svn:ignore properties to .gitignore</strong></p>\n\n<p>If your svn repo was using svn:ignore properties, you can easily convert this to a .gitignore file using:</p>\n\n<pre><code>cd ~/temp\ngit svn show-ignore &gt; .gitignore\ngit add .gitignore\ngit commit -m \'Convert svn:ignore properties to .gitignore.\'\n</code></pre>\n\n<p><strong>4. Push repository to a bare git repository</strong></p>\n\n<p>First, create a bare repository and make its default branch match svn’s “trunk” branch name.</p>\n\n<pre><code>git init --bare ~/new-bare.git\ncd ~/new-bare.git\ngit symbolic-ref HEAD refs/heads/trunk\n</code></pre>\n\n<p>Then push the temp repository to the new bare repository.</p>\n\n<pre><code>cd ~/temp\ngit remote add bare ~/new-bare.git\ngit config remote.bare.push \'refs/remotes/*:refs/heads/*\'\ngit push bare\n</code></pre>\n\n<p>You can now safely delete the ~/temp repository.</p>\n\n<p><strong>5. Rename “trunk” branch to “master”</strong></p>\n\n<p>Your main development branch will be named “trunk” which matches the name it was in Subversion. You’ll want to rename it to Git’s standard “master” branch using:</p>\n\n<pre><code>cd ~/new-bare.git\ngit branch -m trunk master\n</code></pre>\n\n<p><strong>6. Clean up branches and tags</strong></p>\n\n<p>git-svn makes all of Subversions tags into very-short branches in Git of the form “tags/name”. You’ll want to convert all those branches into actual Git tags using:</p>\n\n<pre><code>cd ~/new-bare.git\ngit for-each-ref --format=\'%(refname)\' refs/heads/tags |\ncut -d / -f 4 |\nwhile read ref\ndo\n  git tag "$ref" "refs/heads/tags/$ref";\n  git branch -D "tags/$ref";\ndone\n</code></pre>\n\n<p>This step will take a bit of typing. :-) But, don’t worry; your unix shell will provide a > secondary prompt for the extra-long command that starts with git for-each-ref.</p>\n'}, {'answer_id': 25823518, 'author': 'leftclickben', 'author_id': 1007512, 'author_profile': 'https://Stackoverflow.com/users/1007512', 'pm_score': 2, 'selected': False, 'text': '<p>For <strong>GitLab</strong> users I\'ve put up a gist on how I migrated from SVN here:</p>\n<p><a href="https://gist.github.com/leftclickben/322b7a3042cbe97ed2af" rel="nofollow noreferrer">https://gist.github.com/leftclickben/322b7a3042cbe97ed2af</a></p>\n<h1>Steps to migrate from SVN to GitLab</h1>\n<h2>Setup</h2>\n<ul>\n<li>SVN is hosted at <code>svn.domain.com.au</code>.</li>\n<li>SVN is accessible via <code>http</code> (other protocols should work).</li>\n<li>GitLab is hosted at <code>git.domain.com.au</code> and:\n<ul>\n<li>A group is created with the namespace <code>dev-team</code>.</li>\n<li>At least one user account is created, added to the group, and has an SSH key for the account being used for the migration (test using <code>ssh git@git.domain.com.au</code>).</li>\n<li>The project <code>favourite-project</code> is created in the <code>dev-team</code> namespace.</li>\n</ul>\n</li>\n<li>The file <code>users.txt</code> contains the relevant user details, one user per line, of the form <code>username = First Last &lt;address@domain.com.au&gt;</code>, where <code>username</code> is the username given in SVN logs.  (See first link in References section for details, in particular answer by user Casey).</li>\n</ul>\n<h2>Versions</h2>\n<ul>\n<li>subversion version 1.6.17 (r1128011)</li>\n<li>git version 1.9.1</li>\n<li>GitLab version 7.2.1 ff1633f</li>\n<li>Ubuntu server 14.04</li>\n</ul>\n<h2>Commands</h2>\n<pre><code>bash\ngit svn clone --stdlayout --no-metadata -A users.txt \nhttp://svn.domain.com.au/svn/repository/favourite-project\ncd favourite-project\ngit remote add gitlab git@git.domain.com.au:dev-team/favourite-project.git\ngit push --set-upstream gitlab master\n</code></pre>\n<p>That\'s it!  Reload the project page in GitLab web UI and you will see all commits and files now listed.</p>\n<h2>Notes</h2>\n<ul>\n<li>If there are unknown users, the <code>git svn clone</code> command will stop, in which case, update <code>users.txt</code>, <code>cd favourite-project</code> and <code>git svn fetch</code> will continue from where it stopped.</li>\n<li>The standard <code>trunk</code>-<code>tags</code>-<code>branches</code> layout for SVN repository is required.</li>\n<li>The SVN URL given to the <code>git svn clone</code> command stops at the level immediately above <code>trunk/</code>, <code>tags/</code> and <code>branches/</code>.</li>\n<li>The <code>git svn clone</code> command produces a lot of output, including some warnings at the top; I ignored the warnings.</li>\n</ul>\n'}, {'answer_id': 28364465, 'author': 'it3xl', 'author_id': 390940, 'author_profile': 'https://Stackoverflow.com/users/390940', 'pm_score': 4, 'selected': False, 'text': '<h1><a href="http://www.subgit.com/" rel="nofollow noreferrer">SubGit</a> (vs Blue Screen of Death)</h1>\n<pre><code>subgit import --svn-url url://svn.serv/Bla/Bla  directory/path/Local.git.Repo\n</code></pre>\n<p>It\'s all.</p>\n<p>+ To update from SVN, a Git repository is created by the first command.</p>\n<pre><code>subgit import  directory/path/Local.git.Repo\n</code></pre>\n<hr />\n<p>I used a way to migrate to Git instantly for a huge repository. <br/>\nOf course, you need some preparation. <br/>\nBut you may don\'t stop the development process, at all.</p>\n<p>Here is my way.</p>\n<p>My solution looks like:</p>\n<ul>\n<li><strong>Migrate SVN to a Git repository</strong></li>\n<li><strong>Update the Git repository just before team\'s switching to</strong>.</li>\n</ul>\n<p>Migration takes a lot of time for a big SVN repository. <br/>\nBut updating of the completed migration just seconds.</p>\n<p>Of course, I\'m using <a href="http://www.subgit.com/remote-book.html#7" rel="nofollow noreferrer">SubGit</a>, mama.\ngit-svn makes me <a href="http://en.wikipedia.org/wiki/Blue_Screen_of_Death" rel="nofollow noreferrer">Blue Screen of Death</a>. Just constantly.\nAnd git-svn is boring me with Git\'s &quot;<a href="https://stackoverflow.com/questions/21123415/git-pull-aborted-with-error-filename-too-long">filename too long</a>&quot; fatal error.</p>\n<p><strong>STEPS</strong></p>\n<p><strong>1.</strong> <a href="http://www.subgit.com/download.html" rel="nofollow noreferrer">Download SubGit</a></p>\n<p><strong>2.</strong> Prepare migrate and update commands.</p>\n<p>Let\'s say we do it for Windows (it\'s trivial to port to Linux). <br/>\nIn a SubGit\'s installation <strong>bin</strong> directory (subgit-2.X.X\\bin), create two .bat files.</p>\n<p>Content of a file/command for the migration:</p>\n<pre><code>start    subgit import --svn-url url://svn.serv/Bla/Bla  directory/path/Local.git.Repo\n</code></pre>\n<p>The &quot;start&quot; command is optional here (Windows). It\'ll allow to see errors on start and left a shell opened after completion of the SubGit.</p>\n<p>You may add here <a href="http://www.subgit.com/remote-book.html#7" rel="nofollow noreferrer">additional parameters similar to git-svn</a>.\nI\'m using only <strong>--default-domain myCompanyDomain.com</strong> to fix the domain of the email address of SVN authors. <br/>\nI have the standard SVN repository\'s structure (trunk/branches/tags) and we didn\'t have troubles with &quot;authors mapping&quot;. So I\'m doing nothing anymore.</p>\n<p><em>(If you want to migrate tags like branches or your SVN have multiple branches/tags folders you may consider using the more verbose SubGit <a href="https://stackoverflow.com/questions/23251394/subgit-import-and-multiple-branches-directories">approach</a>)</em></p>\n<p><strong>Tip 1</strong>: Use --minimal-revision YourSvnRevNumber to see fast how things boil out (some kind of a debugging).\nEspecially useful is to see resolved author names or emails. <br/>\nOr to limit the migration history depth.</p>\n<p><strong>Tip 2</strong>: Migration may be interrupted (<kbd>Ctrl</kbd> + <kbd>C</kbd>) and restored by running of the next updating command/file. <br/>\nI don\'t advise doing this for big repositories. I have received &quot;Out of memory Java+Windows exception&quot;.</p>\n<p><strong>Tip 3</strong>: Better to create a copy of your result bare repository.</p>\n<p>Content of a file/command for updating:</p>\n<pre><code>start    subgit import  directory/path/Local.git.Repo\n</code></pre>\n<p>You may run it any amount of time when you want to obtain the last team\'s commits to your Git repository.</p>\n<p><strong>Warning!</strong> Don\'t touch your bare repository (creation of branches for example). <br/>\nYou\'ll take the next fatal error:</p>\n<blockquote>\n<p>Unrecoverable error: are out of sync and cannot be synced ... Translating Subversion revisions to Git commits...</p>\n</blockquote>\n<p><strong>3.</strong> Run the first command/file. It\'ll take a loooong time for a big repository. 30 hours for my humble repository.</p>\n<p>It\'s all. <br/>\nYou may update your Git repository from SVN at any time any amount of times by running the second file/command. And before switching your development team to Git. <br/>\nIt\'ll take just seconds.</p>\n<hr />\n<hr />\n<p>There\'s one more useful task.</p>\n<p><strong>Push your local Git repository to a remote Git repository</strong></p>\n<p>Is it your case? Let\'s proceed.</p>\n<ol>\n<li>Configure your remotes</li>\n</ol>\n<p>Run:</p>\n<pre><code>$ git remote add origin url://your/repo.git\n</code></pre>\n<ol start="2">\n<li>Prepare to initial send of your huge local Git repository to a remote repository</li>\n</ol>\n<p>By default your Git can\'t send big chunks.\n<a href="https://stackoverflow.com/a/18696820/390940">fatal: The remote end hung up unexpectedly</a></p>\n<p>Let\'s run for it:</p>\n<pre><code>git config --global http.postBuffer 1073741824\n</code></pre>\n<p>524288000 - 500 MB\n1073741824 - 1 GB, etc.</p>\n<p>Fix your local <a href="https://www.google.com/search?newwindow=1&amp;espv=2&amp;q=windows+git+unable+to+get+local+issuer+certificate&amp;oq=windows+git+unable+to+get+local+issuer+certificate&amp;gs_l=serp.3...53528.55201.0.55497.12.9.0.0.0.1.398.398.3-1.1.0.msedr...0...1c.1.61.serp..12.0.0.rqc3smB1Tyo" rel="nofollow noreferrer">certificate troubles</a>. If your git-server uses a broken certificate.</p>\n<p><strong>I have disabled <a href="https://stackoverflow.com/a/8755199/390940">certificates</a>.</strong></p>\n<p>Also your Git server may have a <a href="https://stackoverflow.com/questions/13456025/rpc-failed-result-22-http-code-404">request amount limitations needing to be corrected</a>.</p>\n<ol start="3">\n<li><a href="https://stackoverflow.com/questions/6865302/push-local-git-repo-to-new-remote-including-all-branches-and-tags">Push all migration</a> to the team\'s remote Git repository.</li>\n</ol>\n<p>Run with a local Git:</p>\n<pre><code>git push origin --mirror\n</code></pre>\n<p>(<em>git push origin \'*:*\'</em> for old Git versions)</p>\n<p>If you get the following: <strong>error: cannot spawn git: No such file or directory</strong>... For me the full recreation of my repository solves this error (30 hours). You can try the next commands</p>\n<pre><code>git push origin --all\ngit push origin --tags\n</code></pre>\n<p>Or try to <a href="https://groups.google.com/d/msg/msysgit/6bFAPUQDQLI/d_ko7gWViC8J" rel="nofollow noreferrer">reinstall Git</a> (<strong>useless for me</strong>).\nOr you may create branches from all you tags and push them. Or, or, or...</p>\n'}, {'answer_id': 29173307, 'author': 'krlmlr', 'author_id': 946850, 'author_profile': 'https://Stackoverflow.com/users/946850', 'pm_score': 4, 'selected': False, 'text': '<h1><a href="http://www.catb.org/esr/reposurgeon/" rel="noreferrer">reposurgeon</a></h1>\n\n<p>For complicated cases, reposurgeon by <a href="https://en.wikipedia.org/wiki/Eric_S._Raymond" rel="noreferrer">Eric S. Raymond</a> is the tool of choice. In addition to SVN, it supports many other version control systems via the <code>fast-export</code> format, and also <a href="http://en.wikipedia.org/wiki/Concurrent_Versions_System" rel="noreferrer">CVS</a>. The author reports successful conversions of ancient repositories such as <a href="http://en.wikipedia.org/wiki/Emacs" rel="noreferrer">Emacs</a> and <a href="https://en.wikipedia.org/wiki/FreeBSD" rel="noreferrer">FreeBSD</a>.</p>\n\n<p>The tool apparently <a href="http://www.catb.org/~esr/reposurgeon/features.html" rel="noreferrer">aims at near perfect conversion</a> (such as converting SVN\'s <code>svn:ignore</code> properties to <code>.gitignore</code> files) even for difficult repository layouts with a long history. For many cases, other tools might be easier to use.</p>\n\n<p>Before delving into the documentation of the <code>reposurgeon</code> command line, be sure to read the excellent <a href="http://www.catb.org/esr/dvcs-migration-guide.html" rel="noreferrer">DVCS migration guide</a> which goes over the conversion process step by step.</p>\n'}, {'answer_id': 31318711, 'author': 'Nanda', 'author_id': 4990518, 'author_profile': 'https://Stackoverflow.com/users/4990518', 'pm_score': 0, 'selected': False, 'text': '<p>Download the Ruby installer for Windows and install the latest version with it. Add Ruby executables to your path.</p>\n\n<ul>\n<li>Install svn2git</li>\n<li>Start menu -> All programs -> Ruby -> Start a command prompt with Ruby</li>\n<li><p>Then type “gem install svn2git” and enter</p>\n\n<p><strong>Migrate Subversion repository</strong></p></li>\n<li><p>Open a Ruby command prompt and go to the directory where the files are to be migrated</p>\n\n<p>Then svn2git <a href="http://[domain" rel="nofollow">http://[domain</a> name]/svn/ [repository root]</p></li>\n<li><p>It may take few hours to migrate the project to Git depends on the project code size.</p></li>\n<li><p>This major step helps in creating the Git repository structure as mentioned below.</p>\n\n<p>SVN (/Project_components) trunk     -->      Git master\nSVN (/Project_components) branches  -->  Git branches\nSVN (/Project_components) tags      -->      Git tags</p></li>\n</ul>\n\n<p>Create the remote repository and push the changes.</p>\n'}, {'answer_id': 31727222, 'author': 'Josh Benson', 'author_id': 5174258, 'author_profile': 'https://Stackoverflow.com/users/5174258', 'pm_score': 0, 'selected': False, 'text': "<p>GitHub has an importer. Once you've created the repository, you can import from an existing repository, via its URL. It will ask for your credentials if applicable and go from there.</p>\n\n<p>As it's running it will find authors, and you can simply map them to users on GitHub.</p>\n\n<p>I have used it for a few repositories now, and it's pretty accurate and much faster too! It took 10 minutes for a repository with ~4000 commits, and after it took my friend four days!</p>\n"}, {'answer_id': 34879129, 'author': 'Zitrax', 'author_id': 11722, 'author_profile': 'https://Stackoverflow.com/users/11722', 'pm_score': 0, 'selected': False, 'text': '<p>Several answers here refer to <a href="https://github.com/nirvdrum/svn2git" rel="nofollow">https://github.com/nirvdrum/svn2git</a>, but for large repositories this can be slow. I had a try using <a href="https://github.com/svn-all-fast-export/svn2git" rel="nofollow">https://github.com/svn-all-fast-export/svn2git</a> instead which is a tool with exactly the same name but was used to migrate KDE from SVN to Git.</p>\n\n<p>Slightly more work to set it up but when done the conversion itself for me took minutes where the other script spent hours.</p>\n'}, {'answer_id': 35410032, 'author': 'Ruslan Makrenko', 'author_id': 4953065, 'author_profile': 'https://Stackoverflow.com/users/4953065', 'pm_score': 0, 'selected': False, 'text': '<p>There are different methods to achieve this goal. I\'ve tried some of them and found really working one with just git and svn installed on Windows OS.</p>\n\n<p>Prerequisites: </p>\n\n<ol>\n<li>git on windows (I\'ve used this one) <a href="https://git-scm.com/" rel="nofollow noreferrer">https://git-scm.com/</a> </li>\n<li>svn with console tools installed (I\'ve used tortoise svn)  </li>\n<li>Dump file of your SVN repository. \n<code>svnadmin dump /path/to/repository &gt; repo_name.svn_dump</code></li>\n</ol>\n\n<p>Steps to achieve final goal (move all repository with history to a git, firstly local git, then remote)</p>\n\n<ol>\n<li><p>Create empty repository (using console tools or tortoiseSVN) in directory REPO_NAME_FOLDER\n<code>cd REPO_NAME_PARENT_FOLDER</code>, put dumpfile.dump into REPO_NAME_PARENT_FOLDER</p></li>\n<li><p><code>svnadmin load REPO_NAME_FOLDER &lt; dumpfile.dump</code> Wait for this operation, it may be long</p></li>\n<li><p>This command is silent, so open second cmd window : <code>svnserve -d -R --root REPO_NAME_FOLDER</code> \nWhy not just use file:///...... ? Cause next command will fail with <code>Unable to open ... to URL:</code>, thanks to the answer <a href="https://stackoverflow.com/a/6300968/4953065">https://stackoverflow.com/a/6300968/4953065</a></p></li>\n<li><p>Create new folder SOURCE_GIT_FOLDER</p></li>\n<li><code>cd SOURCE_GIT_FOLDER</code></li>\n<li>git svn clone svn://localhost/ Wait for this operation.</li>\n</ol>\n\n<p>Finally, what do we got?</p>\n\n<p>Lets check our Local repository : </p>\n\n<pre><code>git log\n</code></pre>\n\n<p>See your previous commits? If yes - okay</p>\n\n<p>So now you have fully functional local git repository with your sources and old svn history.\nNow, if you want to move it to some server, use the following commands : </p>\n\n<pre><code>git remote add origin https://fullurlpathtoyourrepo/reponame.git\ngit push -u origin --all # pushes up the repo and its refs for the first time\ngit push -u origin --tags # pushes up any tags\n</code></pre>\n\n<p>In my case, I\'ve dont need tags command cause my repo dont have tags.</p>\n\n<p>Good luck!</p>\n'}, {'answer_id': 35605248, 'author': 'Pablo Belaustegui', 'author_id': 5975111, 'author_profile': 'https://Stackoverflow.com/users/5975111', 'pm_score': 3, 'selected': False, 'text': '<p>I\'ve posted an step by step guide (<a href="http://blog.10pines.com/2016/02/24/svn-to-git/" rel="noreferrer">here</a>) to convert svn in to git including converting svn tags in to git tags and svn branches in to git branches.</p>\n\n<p>Short version:</p>\n\n<p>1) clone svn from an specific revision number. (the revision number must be the oldest you want to migrate)</p>\n\n<pre><code>git svn clone --username=yourSvnUsername -T trunk_subdir -t tags_subdir -b branches_subdir -r aRevisionNumber svn_url gitreponame\n</code></pre>\n\n<p>2) fetch svn data. This step it\'s the one it takes most time.</p>\n\n<pre><code>cd gitreponame\ngit svn fetch\n</code></pre>\n\n<p>repeat git svn fetch until finishes without error</p>\n\n<p>3) get master branch updated</p>\n\n<pre><code>git svn rebase\n</code></pre>\n\n<p>4) Create local branches from svn branches by copying references</p>\n\n<pre><code>cp .git/refs/remotes/origin/* .git/refs/heads/\n</code></pre>\n\n<p>5) convert svn tags into git tags</p>\n\n<pre><code>git for-each-ref refs/remotes/origin/tags | sed \'s#^.*\\([[:xdigit:]]\\{40\\}\\).*refs/remotes/origin/tags/\\(.*\\)$#\\2 \\1#g\' | while read p; do git tag -m "tag from svn" $p; done\n</code></pre>\n\n<p>6) Put a repository at a better place like github</p>\n\n<pre><code>git remotes add newrepo git@github.com:aUser/aProjectName.git\ngit push newrepo refs/heads/*\ngit push --tags newrepo\n</code></pre>\n\n<p>If you want more details, read my <a href="http://blog.10pines.com/2016/02/24/svn-to-git/" rel="noreferrer">post</a> or ask me.</p>\n'}, {'answer_id': 36986911, 'author': 'Pankaj', 'author_id': 926520, 'author_profile': 'https://Stackoverflow.com/users/926520', 'pm_score': 3, 'selected': False, 'text': '<p>We can use <code>git svn clone</code> commands as below.</p>\n\n<ul>\n<li><code>svn log -q &lt;SVN_URL&gt; | awk -F \'|\' \'/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" &lt;"$2"&gt;"}\' | sort -u &gt; authors.txt</code></li>\n</ul>\n\n<p>Above command will create authors file from SVN commits.</p>\n\n<ul>\n<li><code>svn log --stop-on-copy &lt;SVN_URL&gt;</code></li>\n</ul>\n\n<p>Above command will give you first revision number when your SVN project got created.</p>\n\n<ul>\n<li><code>git svn clone -r&lt;SVN_REV_NO&gt;:HEAD --no-minimize-url --stdlayout --no-metadata --authors-file authors.txt &lt;SVN_URL&gt;</code></li>\n</ul>\n\n<p>Above command will create the Git repository in local.</p>\n\n<p>Problem is that it won\'t convert branches and tags to push. You will have to do them manually. For example below for branches:</p>\n\n<pre><code>$ git remote add origin https://github.com/pankaj0323/JDProjects.git\n$ git branch -a\n* master\n  remotes/origin/MyDevBranch\n  remotes/origin/tags/MyDevBranch-1.0\n  remotes/origin/trunk\n$$ git checkout -b MyDevBranch origin/MyDevBranch\nBranch MyDevBranch set up to track remote branch MyDevBranch from origin.\nSwitched to a new branch \'MyDevBranch\'\n$ git branch -a\n* MyDevBranch\n  master\n  remotes/origin/MyDevBranch\n  remotes/origin/tags/MyDevBranch-1.0\n  remotes/origin/trunk\n$\n</code></pre>\n\n<p>For tags:</p>\n\n<pre><code>$git checkout origin/tags/MyDevBranch-1.0\nNote: checking out \'origin/tags/MyDevBranch-1.0\'.\nYou are in \'detached HEAD\' state. You can look around, make experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any branches by performing another checkout.\n\nIf you want to create a new branch to retain commits you create, you may\ndo so (now or later) by using -b with the checkout command again. Example:\n\n  git checkout -b new_branch_name\n\nHEAD is now at 3041d81... Creating a tag\n$ git branch -a\n* (detached from origin/tags/MyDevBranch-1.0)\n  MyDevBranch\n  master\n  remotes/origin/MyDevBranch\n  remotes/origin/tags/MyDevBranch-1.0\n  remotes/origin/trunk\n$ git tag -a MyDevBranch-1.0 -m "creating tag"\n$git tag\nMyDevBranch-1.0\n$\n</code></pre>\n\n<p>Now push master, branches and tags to remote git repository.</p>\n\n<pre><code>$ git push origin master MyDevBranch MyDevBranch-1.0\nCounting objects: 14, done.\nDelta compression using up to 8 threads.\nCompressing objects: 100% (11/11), done.\nWriting objects: 100% (14/14), 2.28 KiB | 0 bytes/s, done.\nTotal 14 (delta 3), reused 0 (delta 0)\nTo https://github.com/pankaj0323/JDProjects.git\n * [new branch]      master -&gt; master\n * [new branch]      MyDevBranch -&gt; MyDevBranch\n * [new tag]         MyDevBranch-1.0 -&gt; MyDevBranch-1.0\n$\n</code></pre>\n\n<h1><strong>svn2git utility</strong></h1>\n\n<p><a href="https://github.com/nirvdrum/svn2git" rel="noreferrer">svn2git</a> utility removes manual efforts with branches and tags.</p>\n\n<p>Install it using command <code>sudo gem install svn2git</code>. After that run below command.</p>\n\n<ul>\n<li><code>$ svn2git &lt;SVN_URL&gt; --authors authors.txt --revision &lt;SVN_REV_NO&gt;</code></li>\n</ul>\n\n<p>Now you can list the branches, tags and push them easily.</p>\n\n<pre><code>$ git remote add origin https://github.com/pankaj0323/JDProjects.git\n$ git branch -a\n  MyDevBranch\n* master\n  remotes/svn/MyDevBranch\n  remotes/svn/trunk\n$ git tag\n  MyDevBranch-1.0\n$ git push origin master MyDevBranch MyDevBranch-1.0\n</code></pre>\n\n<p>Imagine you have 20 branches and tags, obviously svn2git will save you a lot of time and that\'s why I like it better than native commands. It\'s a nice wrapper around native <code>git svn clone</code> command. </p>\n\n<p>For a complete example, refer my <a href="http://www.journaldev.com/10618/svn-to-git-migration-complete-tutorial" rel="noreferrer">blog entry</a>.</p>\n'}, {'answer_id': 37684168, 'author': 'PShetty', 'author_id': 2160694, 'author_profile': 'https://Stackoverflow.com/users/2160694', 'pm_score': 0, 'selected': False, 'text': '<p>Converting svn submodule/folder \'MyModule\' into git with history without tags nor branches.</p>\n\n<ul>\n<li>git svn clone --no-metadata\n--trunk=SomeFolder1/SomeFolder2/SomeFolder3/MyModule <a href="http://svnhost:port/repo_root_folder/MyModule_temp" rel="nofollow">http://svnhost:port/repo_root_folder/MyModule_temp</a> -A\nC:\\cheetah\\svn\\authors-transform.txt</li>\n<li>git clone MyModule_temp MyModule</li>\n<li>cd MyModule</li>\n<li>git flow init</li>\n<li>git remote set-url origin\n<a href="https://userid@stashhost/stash/scm/xyzxyz/MyModule.git" rel="nofollow">https://userid@stashhost/stash/scm/xyzxyz/MyModule.git</a></li>\n<li>git push -u origin master</li>\n<li>git push -u origin develop</li>\n</ul>\n\n<p>To retain svn ignore list use the above comments after step 1</p>\n'}, {'answer_id': 41449157, 'author': 'Pedro Vicente', 'author_id': 4739800, 'author_profile': 'https://Stackoverflow.com/users/4739800', 'pm_score': 0, 'selected': False, 'text': '<p>I used the following script to read a text file that has a list of all my SVN repositories and convert them to Git, and later use <code>git clone --bare</code> to convert to a bare Git repository:</p>\n\n<pre><code>#!/bin/bash\nfile="list.txt"\nwhile IFS= read -r repo_name\ndo\n printf \'%s\\n\' "$repo_name"\n sudo git svn clone --shared --preserve-empty-dirs --authors-file=users.txt file:///programs/svn/$repo_name\n sudo git clone --bare /programs/git/$repo_name $repo_name.git\n sudo chown -R www-data:www-data $repo_name.git\n sudo rm -rf $repo_name\ndone &lt;"$file"\n</code></pre>\n\n<p>list.txt has the format:</p>\n\n<pre><code>repo1_name\nrepo2_name\n</code></pre>\n\n<p>And users.txt has the format:</p>\n\n<blockquote>\n  <p><code>(no author) = Prince Rogers &lt;prince.rogers.nelson@payesley.park.org&gt;</code></p>\n</blockquote>\n\n<p>www-data is the Apache web server user, and permission is needed to push changes over HTTP.</p>\n'}, {'answer_id': 48636876, 'author': 'cljk', 'author_id': 1574012, 'author_profile': 'https://Stackoverflow.com/users/1574012', 'pm_score': 2, 'selected': False, 'text': '<p>I´m on a windows machine and made a small Batch to transfer a SVN repo with history (but without branches) to a GIT repo by just calling</p>\n\n<p><code>transfer.bat http://svn.my.address/svn/myrepo/trunk https://git.my.address/orga/myrepo</code></p>\n\n<p>Perhaps anybody can use it. It creates a TMP-folder checks out the SVN repo there with git and adds the new origin and pushes it... and deletes the folder again.</p>\n\n<pre><code>@echo off \nSET FROM=%1 \nSET TO=%2 \nSET TMP=tmp_%random%\n\necho from:  %FROM% \necho to:    %TO% \necho tmp:   %TMP%\n\npause\n\ngit svn clone  --no-metadata --authors-file=users.txt %FROM% %TMP%  \ncd %TMP% \ngit remote add origin %TO% \ngit push --set-upstream origin master\n\n\ncd .. \necho delete %TMP% ... \npause\n\nrmdir /s /q %TMP%\n</code></pre>\n\n<p>You still need the users.txt with your user-mappings like</p>\n\n<pre><code>User1 = User One &lt;u.1@xxx.com&gt;\n</code></pre>\n'}, {'answer_id': 48732137, 'author': 'Anand Tripathi', 'author_id': 5230702, 'author_profile': 'https://Stackoverflow.com/users/5230702', 'pm_score': -1, 'selected': False, 'text': '<h1>For this, I have used <strong>svn2git</strong> library with the following procedure:</h1>\n\n<blockquote>\n  <p>sudo apt-get install git-core git-svn ruby<br>\n  sudo gem install svn2git<br>\n  svn log --quiet | grep -E "r[0-9]+ \\| .+ \\|" | cut -d\'|\' -f2 | sed \'s/ //g\' | sort | uniq > authors.txt (this command is for mapping the authors)</p>\n</blockquote>\n\n<p>Above step should be performed in the folder that you are going to convert from svn to git.</p>\n\n<blockquote>\n  <p>Add one mapping per line in authors.txt like this</p>\n</blockquote>\n\n<pre><code>anand = Anand Tripathi &lt;email_id&gt;\ntrip = Tripathi Anand &lt;email_id&gt;\n</code></pre>\n\n<p>Create a folder for a new git repository and execute the command below having the path of authors.txt</p>\n\n<pre><code>svn2git &lt;svn_repo_path&gt; --nobranches --notags --notrunk --no-minimize-url --username &lt;user_name&gt; --verbose  --authors &lt;author.txt_path&gt;\n\nIf no trunk and no tag and branch is present then have to execute the above command else if root is trunk then mention rootistrunk or trunk is present then --trunk &lt;trunk_name&gt;\n</code></pre>\n\n<blockquote>\n  <p>git remote add origin <br>\n  git push --all origin  <br>\n  git push --tags origin</p>\n</blockquote>\n'}, {'answer_id': 63570098, 'author': 'dgates82', 'author_id': 2209181, 'author_profile': 'https://Stackoverflow.com/users/2209181', 'pm_score': 1, 'selected': False, 'text': "<p>First, credit to the answer from @cmcginty. It was a great starting point for me, and much of what I'll post here borrowed heavily from it. However, the repos that I was moving have years of history which led to a few issues following that answer to the letter (hundreds of branches and tags that would need to be manually moved for one; read more later).</p>\n<p>So after hours of searching and trial and error I was able to put together a script which allowed me to easily move several projects from SVN to GIT, and I've decided to share my findings here in case anyone else is in my shoes.</p>\n<p>&lt;tl;dr&gt; Let's get started</p>\n<hr />\n<p>First, create an 'Authors' file which will translate basic svn users to more complex git users. The easiest way to do this is using a command to extract all users from the svn repo you are going to move.</p>\n<pre><code>svn log -q | awk -F '|' '/^r/ {sub(&quot;^ &quot;, &quot;&quot;, $2); sub(&quot; $&quot;, &quot;&quot;, $2); print $2&quot; = &quot;$2&quot; &lt;&quot;$2&quot;&gt;&quot;}' | sort -u &gt; authors-transform.txt\n</code></pre>\n<p>This will produce a file called authors-transform.txt with a line for each user that has made a change in the svn repo it was ran from.</p>\n<pre><code>someuser = someuser &lt;someuser&gt;\n</code></pre>\n<p>Update to include full name and email for git</p>\n<pre><code>someuser = Some User &lt;someuser@somewhere.com&gt;\n</code></pre>\n<p>Now start the clone using your authors file</p>\n<pre><code>git svn clone --stdlayout --no-metadata -r854:HEAD --authors-file=authors-transform.txt https://somesvnserver/somerepo/ temp\n</code></pre>\n<ul>\n<li>--stdlayout indicates that the svn repo follows the standard /trunk /branches /tags layout</li>\n<li>--no-metadata tells git not to stamp metadata relating to the svn commits on each git commit. If this is not a one-way conversion remove this tag</li>\n<li>-r854:HEAD only fetches history from revision 854 up. This is where I hit my first snag; the repo I was converting had a 'corrupted' commit at revision 853 so it would not clone. Using this parameter allows you to only clone part of the history.</li>\n<li>temp is the name of the directory that will be created to initialize\nthe new git repo</li>\n</ul>\n<p>This step can take awhile, particularly on a large or old repo (roughly 18 hours for one of ours). You can also use that -r switch to only take a small history to see the clone, and fetch the rest later.</p>\n<p>Move to the new directory</p>\n<pre><code>cd temp\n</code></pre>\n<p>Fetch any missing history if you only pulled partial in clone</p>\n<pre><code>git svn fetch\n</code></pre>\n<p>Tags are created as branches during cloning. If you only have a few you can convert them one at a time.</p>\n<pre><code>git 1.0.0 origin/tags/1.0.0\n</code></pre>\n<p>However, this is tedious if you have hundreds of tags, so the following script worked for me.</p>\n<pre><code>for brname in `git branch -r | grep tags | awk '{gsub(/^[^\\/]+\\//,&quot;&quot;,$1); print $1}'`; do echo $brname; tname=${brname:5}; echo $tname; git tag $tname origin/tags/$tname; done\n</code></pre>\n<p>You also need to checkout all branches you want to keep</p>\n<pre><code>git checkout -b branchname origin/branches/branchname\n</code></pre>\n<p>And if you have a lot of branches as well, this script may help</p>\n<pre><code>for brname in `git branch -r | grep -v master | grep -v HEAD | grep -v trunk | grep -v tags | awk '{gsub(/^[^\\/]+\\//,&quot;&quot;,$1); print $1}'`; do echo $brname; git checkout -b $brname origin/$brname; done\n</code></pre>\n<p>This will ignore the trunk branch, as it will already be checked out as master and save a step later deleting the duplicate branch, as well as ignoring the /tags that we already converted.</p>\n<p>Now is a good time to take a look at the new repo and make sure you have a <strong>local</strong> branch or tag for anything you want to keep as remote branches will be dropped in a moment.</p>\n<p>Ok, now lets clone everything we've checked out to a clean repo (named temp2 here)</p>\n<pre><code>cd ..\ngit clone temp temp2\ncd temp2\n</code></pre>\n<p>Now we'll need to checkout all of the branches one more time before pushing them to their final remote, so follow your favorite method from above.</p>\n<p>If you're following gitflow you can rename your working branch to develop.</p>\n<pre><code>git checkout -b WORKING\ngit branch -m develop\ngit push origin --delete WORKING\ngit push origin -u develop\n</code></pre>\n<p>Now, if everything looks good, you're ready to push to your git repository</p>\n<pre><code>git remote set-url origin https://somebitbucketserver/somerepo.git\ngit push -u origin --all\ngit push origin --tags\n</code></pre>\n<p>I did run into one final issue which was that Control Freak initially blocked me from pushing tags that I didn't create, so if your team uses Control Freak you may need to disable or adjust that setting for your initial push.</p>\n"}, {'answer_id': 68242281, 'author': 'Bharathiraja', 'author_id': 2648257, 'author_profile': 'https://Stackoverflow.com/users/2648257', 'pm_score': 0, 'selected': False, 'text': "<p>All in One - shell script for <code>SVN</code> to <code>GIT</code> Migration. Mention the <code>GIT</code> and <code>SVN</code> details with placeholder <code>&lt;&gt;</code></p>\n<pre><code>#!/bin/bash\n\n######## Project name \nPROJECT_NAME=&quot;Helloworld&quot;\nEMAIL=&quot;example mail&quot;\n\n#Credientials Repo\nGIT_USER='&lt;git username&gt;'\nGIT_PWD='&lt;git password&gt;'\nSVN_USER='&lt;svn username&gt;'\nSVN_PWD='&lt;svn password&gt;'\n\n######## SVN repository to be migrated # Dont use https - error will be thrown\nBASE_SVN=&quot;&lt;SVN URL&gt;/Helloworld&quot;\n\n#Organization inside BASE_SVN\nBRANCHES=&quot;branches&quot;\nTAGS=&quot;tags&quot;\nTRUNK=&quot;trunk&quot;\n\n#Credientials\ngit config --global user.name '&lt;git username&gt;'\ngit config --global user.password '&lt;git password&gt;'\ngit config --global credential.helper 'cache --timeout=3600'\n\n######## GIT repository to migrate - Ensure already project created in Git\nGIT_URL=https://$GIT_USER:$GIT_PWD@&lt;GIT URL&gt;/Helloworld.git\n\n###########################\n#### Don't need to change from here\n###########################\n\n#Geral Configuration\nABSOLUTE_PATH=$(pwd)\nTMP=$ABSOLUTE_PATH/$PROJECT_NAME\n\n#Branchs Configuration\nSVN_BRANCHES=$BASE_SVN/$BRANCHES\nSVN_TAGS=$BASE_SVN/$TAGS\nSVN_TRUNK=$BASE_SVN/$TRUNK\n\nAUTHORS=$PROJECT_NAME&quot;-authors.txt&quot;\n\necho '[LOG] Starting migration of '$SVN_TRUNK\necho '[LOG] Using: '$(git --version)\necho '[LOG] Using: '$(svn --version | grep svn,)\n\nmkdir $TMP\necho\necho '[DIR] cd' $TMP\ncd $TMP\n\necho\necho '[LOG] Getting authors'\nsvn --username $SVN_USER --password $SVN_PWD log -q $BASE_SVN | awk -F '|' '/^r/ {sub(&quot;^ &quot;, &quot;&quot;, $2); sub(&quot; $&quot;, &quot;&quot;, $2); print $2&quot; = &quot;$2&quot; &lt;&quot;$2&quot;@&quot;$EMAIL&quot;&gt;&quot;}' | sort -u &gt;&gt; $AUTHORS\n\necho\necho '[RUN] git svn clone --authors-file='$AUTHORS' --trunk='$TRUNK' --branches='$BRANCHES' --tags='$TAGS $BASE_SVN $TMP\ngit svn clone --authors-file=$AUTHORS --trunk=$TRUNK --branches=$BRANCHES --tags=$TAGS $BASE_SVN $TMP\n\n#Not working so no need to mention it\n#--stdlayout $PROJECT_NAME\necho\necho '[RUN] svn ls '$SVN_BRANCHES\nsvn ls $SVN_BRANCHES\n\necho \necho 'git branch -a'\ngit branch -a\n\necho\necho '[LOG] Getting first revision'\nFIRST_REVISION=$( svn log -r 1:HEAD --limit 1 $BASE_SVN | awk -F '|' '/^r/ {sub(&quot;^ &quot;, &quot;&quot;, $1); sub(&quot; $&quot;, &quot;&quot;, $1); print $1}' )\n\necho\necho '[RUN] git svn fetch -'$FIRST_REVISION':HEAD'\ngit svn fetch -$FIRST_REVISION:HEAD\n\n#Branches and Tags  \necho\necho '[RUN] svn ls '$SVN_BRANCHES\nfor BRANCH in $(svn ls $SVN_BRANCHES); do\n    echo git branch ${BRANCH%/} remotes/svn/${BRANCH%/}\n    git branch ${BRANCH%/} remotes/svn/${BRANCH%/}\ndone\n\ngit for-each-ref --format=&quot;%(refname:short) %(objectname)&quot; refs/remotes/origin/tags | grep -v &quot;@&quot; | cut -d / -f 3- |\nwhile read ref\ndo\n  echo git tag -a $ref -m 'import tag from svn'\n  git tag -a $ref -m 'import tag from svn'\ndone\n\ngit for-each-ref --format=&quot;%(refname:short)&quot; refs/remotes/origin/tags | cut -d / -f 1- |\nwhile read ref\ndo\n  git branch -rd $ref\ndone\n  \necho\necho 'git tag'\ngit tag\n\necho\necho 'git show-ref --tags'\ngit show-ref --tags\n\necho\necho '[RUN] git remote add origin '$GIT_URL\ngit remote add origin $GIT_URL\n\necho\necho '[RUN] git push'\ngit push origin --all --force\ngit push origin --tags\n\n#echo git branch -d -r trunk\n#git branch -d -r trunk\n\ngit config --global credential.helper cache\necho 'Successful.'\n</code></pre>\n<ul>\n<li>When you run above script, it will fetch branches and tags details from SVN and put it under <code>.git</code> folder.</li>\n<li>Crosscheck whether all branches are there in the <code>SVN</code> that should be available under this <code>.git/refs/heads</code> folder.</li>\n<li>If some branches are missing which was there in <code>SVN</code> then do manually copy branches files from <code>.git/refs/remotes/origin/&lt;branches&gt;</code> to <code>.git/refs/heads</code></li>\n<li>Only copy branches (including <code>master</code>) and ignore if any <code>tags</code> or <code>trunk</code>.</li>\n<li>Now run the script again. You could see all <code>branches</code> and <code>tags</code> in git repositories.</li>\n</ul>\n"}]
['https://Stackoverflow.com/questions/79165', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14690/']