If you are migrating from TFS (Microsoft) to SVN (Open source) and you want the data with history, you have an option to use GIT and then migrate it.
Below is the procedure of the same:
TFS to SVN with History
- Install “VisualSVN-Server-3.2.2-x64”
- Install “Git-1.9.5-preview20141217”
- Install Chocolatey: open an administrativeexe command prompt and paste the text below:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex
((new-object net.webclient).DownloadString(‘https://chocolatey.org/install.ps1’))"
&& SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
- Copy paste into cmd:
cinst git-tf -force
- Restart Console (USE NORMAL COMMAND PROMPT ONLY IN ADMIN MODE) and point to the location where you want your TFS folder structure:
For e.g.: cd C:/MYPROJECT/
- Then clone the TFS project (your structure will be in C:/MYPROJECT/Training)
git-tf clone http://yourtfsservername:8080/tfs/xyz $/ABC –deep
- Commit (cd to where .git file is present, e.g.: C:/MYPROJECT/Training), REM from the root, add and commit any new files
git add .
git commit -a -m "initial commit after git-tf clone"
- Now you should be able to see all the Repo in Git with history.
- (Now create a SVN Server with link using Visual SVN server and add users and permission to it.) Only for installation SVN server.
- After step 10, you need to parse to the Repository which has been created by the SVN server and do a right click -> GIT BASH to get GIT Command prompt
- Initialize git-svn:
git svn init -s -prefix=svn/ <a href="https://svn/svn/SANDBOX/warren/test2">https://svn/svn/SANDBOX/warren/test2</a>
The –prefix
gives you remote tracking branches like “svn/trunk
” which is nice because you don’t get ambiguous names if you call your local branch just “trunk
” then. And -s
is a shortcut for the standard trunk/tags/branches layout.
- Fetch the initial stuff from svn:
git svn fetch
Steps 13-20 only if there is some problem while performing step no 27.
- Now look up the hash of your root commit (should show a single commit):
git rev-list -parents remote/master | grep '^.\{40\}$'
- Then get the hash of the empty trunk commit:
git rev-parse svn/trunk
- Create the graft:
echo <root-commit-hash> <svn-trunk-commit-hash> >> .git/info/grafts
- Now, “
gitk
” should show svn/trunk as the first commit on which your master branch is based. Make the graft permanent:
git filter-branch - ^svn/trunk -all
- Drop the graft:
rm .git/info/grafts
gitk
should still show svn/trunk in the ancestry of master. Linearize your history on top of trunk:
git svn rebase
- And now “
git svn dcommit -n
” should tell you that it is going to commit to trunk.
git svn dcommit
- Now go to the location where the Repository created from the server is and GIT BASH there.
- cd project
- Add the original Git repo as a remote:
git remote add origin C:/GIT/OPP/.git
- In case the above step went incorrect, you need to remove the origin, by:
Git remote remove origin
And then repeat step number 22.
- Fetch from it:
git fetch origin
- Create a local branch for the remote master:
git checkout -b old_master origin/master
Note that master branch is already present, so we define another one.
- Being on
old_master
, we rebase this branch onto master:
git rebase -onto master -root
Doing this, we have “moved” all our commits from old_master
to master
.
- and push all the commits into the SVN repo:
git svn dcommit
Please note some steps like 23,26, 27 may take a long while (depending on the size of the repository which you are planning to convert. Ideally for 1 GB, it takes 12 hours).