TFS and Git

I recently started working on a new C# project at work. I’ve mostly been doing Dynamics AX (X++) work recently, so it’s been a while since I had a big C# project. With AX, TFS is pretty much the only viable option for source control. So, I just use what’s there, and don’t think about it too much.

With C#, though, it’s pretty easy to use Git too. I’m using Visual Studio 2013, which supports Git directly. I decided to start this project off in Git, just as an experiment. I knew that I’d have to put it into TFS eventually, since our department uses a TFS 2012 server, so I would need to get the source code into that server at some point. But starting off with Git seemed like a good idea, since I knew I’d be making a lot of changes early on, and possibly even discarding the whole project at some point and starting over. So I figured doing all that in a local Git repo would be an efficient and flexible way to start off.

So that’s what I did. I started off with the built-in VS 2013 Git support, which hides a lot of the complexity of Git, and makes it look more like TFS. At the same time, I started reading Pro Git, a pretty hefty book on Git that’s freely available on the web. I’ve used Git before, of course, but I’ve never really spent enough time learning the ins and outs. Pro Git is a pretty good book, and I’m learning a lot from it.

Meanwhile, I also started looking into ways in which I could use Git and TFS in parallel. My idea was that I’d keep using Git locally, allowing me to commit frequently, branch and merge, and just generally manage my work in an agile way. Then, whenever I got to a good stable point, I’d do a TFS check-in.

Skipping ahead a bit, I’ve now switched the project to TFS-only, and have a backup of my .git folder that I’m ignoring for now. I had hoped that I’d be able to switch back and forth easily, in VS 2013, but that’s really not the case. I’ve found that VS 2013, if it sees a .git folder, assumes you’re using git, regardless of any TFS info in your solution file. I had hoped that getting the TFS info into the solution file would cause VS 2013 to use TFS, while I could use Git from the command-line (or via SourceTree).

Alternately, I’ve looked into the possibility of using Git from VS 2013 and doing the TFS commits via the command-line. That actually looks like it might be a possibility, using tf.exe. I might give that a try next week.

I’ve also looked into git-tfs, which is a “two-way bridge” between Git and TFS. I think that would let me keep one branch in a local Git repo synced with TFS, while letting me work locally in a dev branch in Git that I could just merge into the main TFS branch occasionally, or something like that. I’m not entirely clear.

And yes, I know that if we could upgrade our server from TFS 2012 to TFS 2013, I could use the native Git support in TFS 2013. But that’s not something we can do right now, largely because it might not be compatible with Dynamics AX 2012, and doing the upgrade would be too much of a distraction and risk right now. (Similarly, Microsoft’s hosted TFS would be great, but almost definitely wouldn’t work with our current AX setup.)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.