Pulling history from TFS is time consuming. Please be patient and keep an eye on your migration.
We need to install the tooling git-tfs
on the local machine to help convert data from the TFS format to Git.
- Go to Chocolatey Install
- Follow instructions to install Once you have installed, run command to install git-tfs
choco install gittfs
Navigate to:
- Releases
- Select the latest full release
- Unzip the binary on your local machine
- Set in a location that is easy to path
- Open
GitBash
shell and set the path:set PATH=%PATH%;\GitTfs-Version
- Or you can set in your full path location if easier to achieve
- Validate that the tool is pathed correctly
git tfs help
- You should see the standard help page for the tooling
You can follow the documentation in the main repository:
- Migration Doc You will need to create a small workspace on your local machine to do the clones and cleanups away from your development environment.
git tfs clone https://TFS-Server-Name:443/tfs/Collection $/project/trunk . --branches=all
- This is the longest and most expensive; it also could have the most errors
git tfs clone https://TFS-Server-Name:443/tfs/Collection $/project/trunk . --branches=auto
- This is a cleaner version with some of the history
git tfs clone https://TFS-Server-Name:443/tfs/Collection $/project/trunk . --branches=none
- Only history for what is in
master
; this clean and efficient
- Only history for what is in
git tfs clone https://TFS-Server-Name:443/tfs/Collection $/project/trunk . --changeset=3245
- We're really reaching for some history at this point... going off the beaten path... This is not advisable
git tfs quick-clone https://TFS-Server-Name:443/tfs/Collection $/project/trunk .
- Just the latest changeset that was pushed into
master
- Just the latest changeset that was pushed into
You can now clean the commits, remove trash, etc
git filter-branch -f --msg-filter "sed 's/^git-tfs-id:.*$//g'" -- --all
- Delete the git folder
rm -rf .git/refs/original
- Add optional gitignore file:
Log into GitHub.com and navigate to your Organization. You will need to create a repository that is ready for the initial push
- Select to create repo and do NOT initialize with
README.md
or.gitignore
- Select the naming scheme you would like to follow and name the repository
- It will give you the origin and push commands that you need to run on your shell to push the code to GitHub
echo "# RepoName" >> README.md
echo "TFS History for this repo can be found at: [RepoName](tfs.com/path) " >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:<YourOrganization>/<RepoName>.git
git push -u origin master
- Change directory into your migration folder and run the following commands
rm -rf * .git .nuget
- Verify the folder is clean
ls -la
- If it the folder is clear, you can start the next repository migration
If the customer is utilizing TFS 2017+ or greater, or is utilizing Microsoft Azure DevOps, then they have the opportunity to migrate their source code data from tfsvc
to git
utilizing the SCM tool. The short comings to this method:
- The built in will migrate the source for up to
6
months backwards in history - The built in will only migrate the master branch
If this is acceptable to the end user, then they can follow the information outlined below: