I’ve written about how I “ like git over TFVC ” recently. We can’t always change things and it’s not always wise to do so. I’ve found that I can still use Git locally to have the goodies of Git (a history of commits, branches, stashing, fast switching between branches). This is especially useful for long running changesets (I know you’re not supposed to have those, but you can’t change everything).
I used this successfully for a long lived changeset. TFVC seems to be tied (I’m making a broad assumption) to processes that require Dev/Main/RC branching and promotes one changeset per branch to make the merging easier later. I worked on the same thing for a month! I only used master in git. The small commits helped me stay on track, gave me some freedom to experiment and go back. I was easily able to see what I pulled in with get latest. I also could make a small experimental branch to test things out.
I attempted using Git inside of TFVC for a couple hour bug fix and it was not worth it. You can read what I tried below.
Update: 4/29/2020. I recommend
over my approach below. However, I was unable to get the check-in tool to work. The recommendation was to install Visual Studio 2015. I didn’t do that, but it’s easy to create a shelveset with
git tfs shelve 'xyz' and finish the check in with VS and TFVC.
git status will show you have a repo running.
In File Explorer you’ll now have a new
Add all the files to master using
git add . and
git commit -m "init".
If you wanted to do it, here’s what I tried out and found
Create a branch and check it out with
git checkout -b <branch-name>.
Now use Git as normal with small commits.
Create a TFVC shelveset at the end of the day. This will help you make sure you’re getting all the right files marked in TFVC for add/remove/rename/delete, etc.
Interruptions happen all the time. You’ll also need to do a Code Review and it may take awhile for the team to give you feedback. If you switch your branch back to master, the Visual Studio TFVC pending changes will still show those as pending. So you’ll still want to need to use Suspend Changes :-(.
You will need to commit or stash your changes.
git checkout master.
Suspend your changes in Visual Studio, My Work.
Get Latest in Visual Studio.
Commit to master.
git add .,
git commit -m "got latest"
git checkout <branch-name>
git rebase master
Click Resume in My Work of Visual Studio. Then, you’ll get merge conflicts. Click Keep Local File Contents (since you’ve already gotten them from Git).
The git-tfs tool may be what you want to try out. “git-tfs is a two-way bridge between TFS (Team Foundation Server) and git, similar to git-svn. It fetches TFS commits into a git repository, and lets you push your updates back to TFS.” I may come back here and add what I learned trying that out.
I worked with a guy who used git-tfs for a couple of months while the company did training and got people ready to move to Git. He became the Git Guru and helped me out of several Git messes as I was learning.
choco install gittfs
In a Migrating from TFVC to Git talk, he shows migrating then talks about Git-TFS (minute 5 and on).
git commit -m "got latest".
Sometimes (for various reasons) you can’t just move your team to Git . You can use Git, but don’t get the benefit of branches (without a lot of trouble).
Please consider using Brave and adding me to your BAT payment ledger. Then you won't have to see ads! (when I get to $100 in Google Ads for a payout, I pledge to turn off ads)
Also check out my Resources Page for referrals that would help me.