Version Control with TFS 2013 Git Repository

Posted by Sahas Subramanian - August 02, 2013

header-picture

 

For brief introduction to Git + VS ALM, spend a few minutes here.

Here is a simple developer workflow and we'll see how that works from within VS 2013 Preview

Above 4 steps will help cloning the repository to a local path. That's all, I don't need to be connected to the server until I'm ready to submit my changes

Within Team Explorer, Solutions tab will take us from here. Solutions tab will list the branch I'm on currently, all the solutions available and link to create a new solution.

 

Now, I've added some projects and files to version control for the first time..after moving those files into your physical directory.. If you navigate into "Changes" from Team Explorer, all those changes will appear in "Untracked Files"

By selecting "Add All", all these changes will be added and ready for Commit

If I switch back to Git Bash command line and run git status, I'll get the same result there too..

I can just provide comment and Commit the changes from VS

Now, as we do it for the first time, the whole branch needs to be "Published"

Next time onwards, if a file added or modified, you will commit the change and those changes are staged in Index.

This is equivalent to git add command

Now, from the staging area, I can push it to the centralized repository

In the picture below, my staging area has 2 changes accumulated and waiting to be Pushed

Each Commit has unique identified associated to it and at any point, user can view complete details related to that commit by selecting "View Commit Details"

Even, if I were to make changes to the same file, over and over, every single change will be tracked as separate Commit.. picture below shows that I'm changing the same file and staged then as separate commits

Whenever you are ready to Submit changes to the centralized repository, go online and click "Push"

To lookup historical changes, go to Branches within Team Explorer, right click on the branch and select "View Hisory"

With this version, VS will Push all the Commits and won't allow you to selectively Push..

If you have a need to perform selective push, command line is the choice.

Get the SHA hash from log and Push as shown below

$ git log

commit 7faa08faba0d62d308af1ec8e982a46ecc7b13a1

Author: Sahas_Incycle <sahas.subramanian@incyclesoftware.com>

Date: Fri Aug 2 16:05:08 2013 -0700

Changing BusinessImpact allowed values

$ git push origin 7faa08faba0d62d308af1ec8e982a46ecc7b13a1:master

Some of the other common usages are Branching and Merging.. by nature, Git's branching is super simple.. While creating a branch Git doesn't copy files, instead, Branch is a reference to a commit and history is extracted using commit relationships. Merge is never single click in any tool, but, Git makes it much easier experience

So, from VS, Team Explorer à Branches.

This will list all published branches, should match the result of git branch –list.

Merge is very straight forward too from VS.. from Team Explorer, select source and target branches to perform merge.. Merged content is Committed in the target branch where you need to review and Push..

Incase of conflicts, VS offers you merge conflict resolution options and then commit

Merge brings in all the history from the source branch as shown below

Here is pretty good cross branch visualization from Source Tree

Server side Version control structure, history and much more options are available from the Web UI

  1. Version control structure
  2. History
  3. Branches
  4. Cloning that remote repo locally
  5. Search by Commit Id

Below screen shows

  1. History of a branch.. I got about 3 years data migrated from public SVN project and trust me the history loads in about 30 seconds
  2. Advanced search options
  3. Search by Commit Id

Below is the visualization of current state of the branches

Compare branches, look at the differences side by side…

 

Hope you agree that VS 2013 has adequate Git integration to encourage Git fans and more to come.. Thanks for reading this article J

Topics: Blog


Recent Posts

InCycle Named Azure Data Explorer (ADX) Partner

read more

OpsHub & InCycle Help Top Medical Device Company Accelerate Innovation

read more

InCycle Continues to Lead, Recognized by Microsoft for Industry Innovation. Earns Impact Award.

read more