How to work with Git from command line (Windows)

It’s very important to know the commands behind the UI in Visual Studio, in this post I just explain the basic you need to work with Git from the command line.

The first step is to set the global settings, but first list display what it’s value.

git config –global -l
If there is no settings it will tell you no such a file, if there is data it will be displayed as the following:
git config --global -l

If you open the user folder, you can see that file .getconfig, also if you open the Visual Studio and navigate to global settings you will find that this info has been set too.

I can also edit this file using VIM
git config --global -e

This will open Unix editor, to quite that window I need to type :q +enter
you can press i to start entering text and save by pressing esc and :wq and enter, this will commit with the message you typed. In your current state, to just come out without committing, you can do :q
git config --global -e edit

If you open the file without a proper exit, it will create a swap file and you can’t open it again smoothly, you just need to delete that swap file or close the file as mention before


Navigate to the directory you want to use and type:
git init
git clone

This will copy all files to your local files, try to add new file and then add it using
git add .

Try to see the status using
git status

Commit the changes
git commit -m ” your message”

Change the branch
git checkout branchName

Push changes
git push

Sync between my GitHub and Visual Studio Online

I needed to sync between my project on GitHub and Visual Studio Online, and to do so I used Git remote which enable to connect to a remote repo and then pull from it and push to the other repo.

First I need to enable Alternate authentication credentials for my account on VSO
Alternate authentication credentials VSO

I open my local repo with Visual Stuido 2015 which is connected to my VSO

I add remote repo by open the command line to that local repo and type:
git remote add github
git remote add github

Select the local branch by double click(not from remotes), make sure it’s bold
Select origin branch on Git

You can also use the command line instead of Visual Studio, just type git checkout the needed branch, if you look at the Visual Studio, you will notice it’s also bold
git checkout branch

Now, you can pull from the needed branch for example:
git pull github dev
git pull github
Push to the VSO
git push origin dev
git push origin
I will need to do that with each branch, I can remove the remote repo by type:
git remote remove github

I will keep the remote repo to sync later.

Also I can remote repo to VSO by type:
git remote add vsonline

How to Upload a Virtual Machine to the Cloud for Microsoft Azure

Recently, I worked with Microsoft Azure to provide better solutions using Visual Stuido 2015 and Team Foundation Server 2015 and Visual Studio Online, here…I will just share my experience about that through a new series which introduce different and random features for Microsoft Azure

  1. How to Upload a Virtual Machine to the Cloud for Microsoft Azure


How to Upload a Virtual Machine to the Cloud in Microsoft Azure

  1. Create a container inside the Storage


  1. Create a storage. I named my storage vmsmra


  1. Click on the storage <vmsmra> to see the containers inside


  1. Select which container you want to use to upload your virtual hard disk. (In this walk-through I choose uploadedvhds
  1. Open the machine that you will use to upload. In this case we use Azure Powershell.

Note: If you don’t have yet Azure Powershell, you can download it from Github or just use the direct link which I prefer.



  1. After installing, run Microsoft Azure PowerShell

Note: You can type help azure and this will display all the commands that will help you in doing your work


  1. First thing you need to do is to connect to your Azure account. You can do this by typing Add-AzureAccount then press Enter


  1. Login page for Microsoft Azure will pop-up. Enter your email address and click Continue.


  1. Then it will ask you to sign into your Microsoft Account. Enter your email and password then click Sign in


  1. After connecting your Azure subscription, it should look something like this:


  1. Then you need to add the vhd by typing

Add-AzureVhd –Destination <destination path> -LocalFilePath <local file path>

Then press Enter


  1. You will then see that it is starting to calculate MD5 Hash. This step may take a while to complete before you can see the result.



  1. After creating MD5 hash, it will start detecting empty blocks and this usually last for 10 minutes


  1. After successfully uploading the vhd, it will look something like this:

As you can see, it took me 1 hour and 27 minutes to upload my vhd (80 GB)


  1. Now go to Storage > vmsmra


Under vmsmra, click  uploadedvhds to view your uploaded vhd


Clicking uploadedvhds will show you the vhds you uploaded. It will also show the size of your VHD


  1. Now we are ready to create our disk. First you need to click Virtual Machines, then click Disks


  1. After clicking Disks, it will display all the names of the disk and its details. To create a new disk, you need to click +Create found below


A pop-up window will be displayed


  1. Fill up the box by typing the Name, VHD URL (location of your uploaded vhd) and the operating system family. Then click Open


After that, you will see that it is starting to create the disk


After few minutes, it will now show that the disk has been successfully created


  1. We are now ready to create our virtual machine. To do this, under Virtual Machines, click Instances then click New found at the bottom.


It will show a window where you can create your virtual machine.


After that, this window will open. Name your virtual machine, leave the Tier to Standard then select the memory size of your virtual machine.


After that, details of your virtual machine configuration will be displayed


  1. It will now show that you successfully created a virtual machine and need to wait as it is starting provisioning


You will know that it is completed once the status changed to “Running”


  1. To connect to the machine, go to Virtual Machines, then select your virtual machine and click Connect found at the bottom


It will then show that it is downloading  the .rdp file. Click OK

  1. Open your .rdp file on your local machine, then click Connect


  1. Enter your credentials, the establish the remote desktop connection


And you can now access the machine of Brian Keller that you uploaded in Windows Azure


Microsoft Visual Studio Team Foundation Server 2015 Process Editor errors

As we know that Visual Stuido 2015 and Team Foundation Server 2015 has been released, when I started working with the new TFS Power Tool, I found that there are some errors comes with the Process Editor tool.

If we try to customize some types of the work-items, we might see the following error:
Control ” references a non-existing field System.ID.
non-existing field System.ID

We just need to change the name of the control to the right one with the small letters as the following:

Another error:
VS402479: You can’t overwrite the Scrum process template, because it’s locked. For more information about customizing process templates, click ‘Help’.
VS402479 You can't overwrite the Scrum process template, because it's locked. For more information about customizing process templates, click Help.

We just need to generate GUID and add it to the ProcessTempalte.xml file as the following:
GUID for TFS Process Template

Another error that Reason field is read only for the Product Backlog Item, so no matter what you added extra reasons, it wouldn’t appear, to fix that we just need to change that to false, see the following image:
ProductBacklogItem layout

Unable to create workspace due to a mapping conflict

It’s a small issue, you may encounter if you name your build definition with the same name as an old one.

Here is the error
Exception Message: Unable to create the workspace ’80_6_tfs2bld’ due to a mapping conflict. You may need to manually delete an old workspace. You can get a list of workspaces on a computer with the command ‘tf workspaces /computer:%COMPUTERNAME%’.  Details: The path C:\Builds\6\Windows\src is already mapped in workspace 77_6_tfs2bld. (type MappingConflictException) Exception Stack Trace: at Microsoft.TeamFoundation.Build.Workflow.Activities.TfCreateWorkspace.Execute(CodeActivityContext at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager,

Unable to create the workspace due to a mapping conflict

You will need to go to the build machine, search for the old workspace that use the same build definition name, delete that one so the build can create new worksapce with the same name again.
Delete workspaace

Create One Main Build Process to Invoke Other Builds

The main question was….. How to start a build when another build succeeds in TFS, in other word.. how to invoke a TFS Build from another TFS Build?

I don’t need to use any third-party library to do so, all I had to do is to edit the default Lab Management process temple which is already did that (invoke a build from other build).

I copy the build process and remove most of the activities, variables and arguments and do some modifications, the following is an image of all the process and I will explain what happen in each section:
Master Build run other builds all the process

Here is the Build definition that use the process, it’s only has 4 arguments, we can see that build definitions arguments is a list of string so we can point to many build as needed, also we have option to run build in sequence if builds depend on each other or disable that in case no dependencies.
Master Build run other builds-build definition

In the following section, I just added a loop (For Each) that iterate over the list of given builds and invoke each one, note here that I check if we want run the build in sequence, see the next step.
Run other workflow TFSBuild for each build definitions

If we want to run the build in a sequence (the condition is true) to make each build depends on the previous build status and if one build fail then the main build will stop and fail.
To do so, I wait for the build untill finished and change the main build status (success or fail) and if it  fail then the main build stop and fail (ThrowOnError), if it success, it go to the next iteration in the loop (wait for the next build).
Run build in sequence wait for build and set build status

If we don’t want to run the build in sequence (condition is false) we just need to trigger all builds with no dependencies, that’s means the main build always success even other child builds fail because it’s not depends on them, even the main build may finish while other build still running, I made the main build wait for the last triggered build in the loop but if last build finished before the previous one, the main build will finished before all build finished, I also changed (ThrowOnError) to be false so the main build will not fail if the last build fail.
Wait for the last build and success the build whenever

Downlaod process template