Migrate TFS projects into GIT with history
I recently worked at a company that was still working with TFS (2012), they wanted to move everything to Git but where afraid to lose the history of the projects. So I wrote the following guide for them:
The guide will be explaining the proces of converting a TFS project to GIT with conserving the History. This guide is only usefull when having a GIT repository and a TFS repository.
The following tools and frameworks will be used during this guide:
Npm – https://nodejs.org/en/
Git for Windows – https://git-scm.com/
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Chocolatey (optional) – https://chocolatey.org/
Easily manage all aspects of Windows software (installation, configuration, upgrade, and uninstallation). Chocolatey works best when software is included in the package, but can easily download resources.
1 Getting started
We are going to use an old solution that still works for migrating the code to GIT. We are going to use Git-TF (2004). The installation of this would be easier if you have Chocolatey installed.
Chocolatey will add all the needed Path automaticaly and install the required frameworks.
$ choco install git-tf -y
- Install java (IF not yet installed)
- Download the zip code: git-tf-126.96.36.19931219.zip
- Add the path where you extracted Git-TF (i.e. C:\git-tf) to your PATH environment variable.
- Add the path where java.exe is installed (i.e. C:\Program Files (x86)\Java\jre7\bin) to your PATH environment variable.
Clone your TFS team project from the commandline to the directory of your choice.
$ git-tf clone http://myteamfoundationserver/DefaultCollection $/myProject/branch –deep
This can take a while depending on your history. After receiving all the data, it’s time to clear some TFS specific data.
Remove TFS source control bindings from solution. This can be done by removing all the *.vssccfiles and change the .sln file by removing the GbloablSection (TeamFoundationVersionControl) …
Add a .gitignore file and add the following code:
#Visual Studio files
This will ensure all of the build generated files, packages, and even your resharper cache folder will not be committed into your new repo.
Adding .gitignore in windows: create new file with the name ‘.gitignore.‘ the last dot is needed to be able to create this file.
Add an optional Readme.md file. Great way to quickly outline things about the project that would be usefull.
3 Commit to GIT
Now that we have git-ified the repository, it’s time to commit the files, add the remote, and push the new branch to the GIT repository.
:: from your selected folder, add and commit all files
$ git add .
$ git commit -a -m “initial commit after migration”
:: add Git Remote
$ git remote add origin http://yourGitRepository
:: Push code to master
$ git push origin master
:: Login with your credential
We have completed the migration, you are free to delete the GIT-TF from choco or your manual installation. Before deleting the TFS project please take a look if everything has been migrated correctly.
EXTRA: Tutorial git-flow
The following tutorial will explain you how git flow works:
HAVE FUN WITH GIT