A starters guide to Git for TFS GitWits…

When I started my development career way back in 1999, the first Source Control System I ever used was Visual SourceSafe. After a few years I switched to SVN for a while and I liked that. The, in 2005 came Team Foundation Server and I embraced it, including the Source Control of course. And since then I must say, I really like TFS Source Control. You need to remember that the server must always know what you are doing, but once you know that and practice that it is simply a great and easy to use Version Control System.

When TFS 2012 introduced Local Workspaces, it became even better, because now all the advantages of TFS and all the advantages of a system like for example SVN were combined. The perfect world !

But then came Git. And I must say that is something different. When I first heard that Git would become a part of TFS I tried to understand the concepts etc. I was a Git NitWit (or a GitWit?).

There are many great posts and blogs about what Git is. The book Git Pro, which is available online, does a great job in explaining the concepts. The most important thing to know is that Git is a Distributed Version Control System (DVCS). TFS is a Centralized Version Control System. TFS knows about all the changes that happen. You check out a file, edit the file and check it in. The server knows. History is on the server. Therefore you need to be “online” in order to use a Centralized Version Control System. A DCVS is different. You get a full copy of a repository that is stored somewhere (in the cloud for example) including all the history etc. Then you work locally on this repository. You can check-in changes, view history and rollback if you like. After working for a while you can then push back all the changes to the repository where you originated from.

At the end of the post, you find a few links to other resources. I would recommend you to look at the TechEd 2013 video of Martin Woodward about Git. Martin talks a bit about the concepts and gives some nice demo’s.

Because I found it very hard to grasp Git at first and even harder to “translate” Git to TFS VC, I created a small dictionary. I am aware that not everything can be translated 1 to 1, but it helps you understand the concepts a bit more.

Dictionary

In this post I will talk about the following definitions

Git Actions TFS Command
Clone Create Workspace and Get Latest
Checkout Switch workspace / branch
Commit CheckIn / Shelve
Status Pending Changes
Push CheckIn
Pull Get Latest Version
Sync (Push and Pull. Only exists in VS UI) CheckIn and Get Latest Version

Clone vs. Create Workspace and Get Latest

[Clone] in Git means that you get a local copy of a full Version Controlled repository that is stored somewhere. You basically pull everything on to your local machine. Clone is the first thing you need to do when you start working with a Git repository.

In TFS we first [create a workspace], map the server folder to a local folder and [Get the Latest Version] of all the files in our workspace.

clip_image002

Create a repository clone in Git

clip_image004

Create a workspace in TFS Version Control

Checkout vs. Switch workspace / branch

[Checkout] in Git, means change the branch you are working on. This is something that we do not have in TFS. Sure we have branches in TFS, but they are in separate folders and locations on disk and in the repository.

clip_image005

Branches in TFS Version Control

In Git this is not the case. You just have 1 view on the repository and the branches are “contained” within this repository. Switching branches is very easy to do (easier than in TFS I must admit) and files directly change.

In TFS a best practice is, that you create a separate workspace per branch you are working on. When you want to work on another branch, you [change your workspace] open the solution from this workspace and start working. In Git you can use the command [Git Checkout] or just use the DropDown lists in the UI.

clip_image006

Switch Git branch in TFS Web Access

clip_image007

Switch Git branch in Visual Studio

Commit vs. CheckIn / Shelve

This one is also not entirely true. In TFS you can press [Checkin]. The client sends all the files to the central TFS repository and the files are available to everyone. In Git you can [Commit] your changes when finished. Big difference here is that in Git, you always [Commit] to your “local” repository. Changes are not available on the original branch where you came from. You have to [Push] your changes as a second action to “check-in” on the server.

In TFSVC you cannot commit locally. The closest thing to checking in for yourself is a shelveset.

clip_image008
Git Commit

clip_image009

Git Push

clip_image010

TFS Checkin

Status vs. Pending Changes

In Git you can use the command [Git Status]. It shows you all the modified files in your local repository that have not been Pushed. In TFS we have the view Pending changes windows (which is dockable in VS 2013 !!). In the UI it looks quite the same and has the same behavior.

Beware of the branches in Git.

clip_image011

View Status in Git

Push vs. CheckIn

When you want to send your changes to the remote repository where you originated from in Git, you can use the push command. With this command, you send all your local commits to the remote repository. In TFS you use checkin for this. Because there is only 1 central server you always checkin on this server.

clip_image012

Push in Git

Pull vs. Get Latest Version

To get all commits from the originator repository that were made by others, you can use the pull command. With this command you retrieve all the changes.

In TFS we use the [Get Latest Version] of [Get Specific Version] command to synchronize the workspace.

clip_image013

Pull in Git

clip_image014

Get Latest Version In TFS

Sync vs. CheckIn and Get Latest Version

Sync is not really a Git Command. You use Push and Pull. Visual Studio created a nice graphical button to do this together.

clip_image015

Sync button in Visual Studio

Hopefully this makes things a little bit more clear. To get some feeling with branching in Git, I recommend this post, which does a great job in explain a possible strategy in Git.

Resources:

Related Posts:

Advertisements

8 Responses to “A starters guide to Git for TFS GitWits…”

  1. Reblogged this on Agile and ALM and commented:
    This is a great blog post for those users who have hesitated adopting TFS as an ALM tool because of their dislike of TFS source control. René covers the advantages of using Git with TFS, and also maps it out for users who want to make the transition.

  2. Reblogged this on Mark van den Berg and commented:
    My Delta-N collegue René van Osnabrugge created a nice blog about the Git integration in Team Foundation Server. It’s a good starting point for TFS users who want to adopt as Version Control System

  3. Reblogged this on yuriburger.net and commented:
    Collegue René van Osnabrugge created this excellent post about using Git with TFS.

  4. Reblogged this on Unravelling Software Development and commented:
    Perfect “map” to assist in finding some common ground between Git and Tfs!
    When coming from a visual SourceSafe / Tfs background the transition to Git can be a bit intimidating.
    I found this blog post by Rene van Osnabrugge really helpful to get a foothold into the Git world.

Trackbacks/Pingbacks

  1. A starters guide to Git for TFS GitWits…... - August 8, 2013

    […] When I started my development career way back in 1999, the first Source Control System I ever used was Visual SourceSafe. After a few years I switched to SVN for a while and I liked that. The, in 2…  […]

  2. Combining TFS Version Control and Git with Git-TF | The Road to ALM - March 27, 2014

    […] If you are new to Git terminology, read my blog about some definitions. […]

  3. Slides from my sessions on TechDays 2015 | The Road to ALM - June 2, 2015

    […] This talk was inspired by this blog post […]

  4. VSLive 2015 in Austin, TX! - Madison Web Design, Wordpress Services, and Search Engine Optimization - June 5, 2015

    […] was even asked as a question from the audience, but the answer escapes me now. There is a whole new set of terminology I’m going to have to adopt for […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: