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 !
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.
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|
|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.
Create a repository clone in Git
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.
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.
Switch Git branch in TFS Web Access
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.
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.
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.
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.
Pull in Git
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.
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.
- Git Basics – http://git-scm.com/book
- Announcement of Git and TFS – http://blogs.msdn.com/b/bharry/archive/2012/08/13/announcing-git-integration-with-tfs.aspx
- Wikipedia Definition – http://en.wikipedia.org/wiki/Git_(software)
- TechEd 2013 video of Martin Woodward – http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/DEV-B330#fbid=Lb7e4eYEDpC
- Use Git in Visual Studio – http://blogs.msdn.com/b/visualstudioalm/archive/2013/02/06/set-up-connect-and-publish-using-visual-studio-with-git.aspx
- A successful Git branching model – http://nvie.com/posts/a-successful-git-branching-model/
- All Source Control Posts – https://osnabrugge.wordpress.com/category/team-foundation-server/source-control/