Last active
November 30, 2017 07:08
-
-
Save ChrisCarrAu/ee69ec381780b717ec77e74db31ff10f to your computer and use it in GitHub Desktop.
Converting TFS to Git (maintaining TFS labels in Git)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Migrating TFS to Git is relatively straightforward with tools such as git-tfs, but how to do it and maintian your labels in a useful way? This is the problem I had to solve recently and this is how I did it. | |
Requirements: | |
1. Migrate all version control history (10+ years) from TFS to Git | |
2. Maintain all of the labels in TFS which were used to mark code releases so that the correct version of code can be hot-fixed or reviewed. | |
I tried to migrate this all in a single Git repository, but the TFS repository had been branched sufficiently that it made the result unintelligible. | |
I opted for a cleaner approach which met the requirements and also gave the developers a solid platform from which to start with their new Git repository. Create two Git repositories. One for history containing all of the source, atomic checkins and commit comments, and the other containing the releases (from labels) and which would be the base for the new repository. | |
The following batch file accepts two parameters | |
- the subfolder in TFS under which the label was created | |
- the name of the label | |
It is run once per label to create an entirely new Git repository in a subfolder with the same name as the label. (Warning: labels must be valid folder names) | |
----------------------------------------------- | |
@echo off | |
IF EXIST %2 GOTO exit | |
rem working folder | |
md %2 | |
if %errorlevel% NEQ 0 goto exit | |
cd %2 | |
rem Get the source from TFS by label | |
tf workspace /new /noprompt /s:http://[repository-address] MyWorkspace | |
tf workfold /map "$/[repository-main-folder]/%~1" . | |
tf get * /r /version:"L%~2" | |
git init | |
echo #%~1 > readme.md | |
echo ##%~2 >> readme.md | |
echo. >> readme.md | |
echo. >> readme.md | |
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%b-%%a %time%) | |
echo Created on %mydate% >> readme.md | |
git add -A && git commit -m "Original creation" | |
tf workspace /delete /noprompt MyWorkspace | |
cd.. | |
:exit | |
--------------------------------------------- | |
After this has been run, each repository is ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment