You’ve migrated your code base (or as much of it as you can) from TFVC and now a user just realised they need some super important code from a shelveset. How does one go about migrating this? As far as I see it, you have three options.
- Manually copy the changes over.
- Unshelve the changes, commit to the branch and pull in to the Git repository.
- Use the git-tfs unshelve command.
In my case the shelve was too big for option 1 and too old / contained breaking changes for 2, leaving option 3.
One thing to note that when migrating a shelve from TFS, it will create a new branch against master. In my case, I wanted a new branch against a development branch.
What I want:
master _development _shelveset branch
What git-tfs does:
master _development _shelveset branch
But hey, this is Git, so it’s no problem!!
# Get the shelveset from TFS and stick it in to a new branch git tfs unshelve -u="Shelveset Owner Name" "Shelveset Name" TargetBranchName_TEMP # Checkout that new branch git checkout TargetBranchName_TEMP # Get the hash for the head of the new branch git log --pretty=format:%h -n 1 # Now switch to your dev branch git checkout development # Create a new branch for the shelveset git branch TargetBranchName git checkout TargetBranchName # Merge the temp shelveset branch in to it's final location git cherry-pick HASH # You might have some things to merge now. git commit -m "Migrated shelveset 'Shelveset Name'"