Step-by-step guide on how to install and use Git on with Team Foundation Server (TFS)

In this tutorial, we are going to show you how to install and use GIT on Team Foundation Server.

1 – GIT INSTALLATION

-        First we have to make sure that our visual studio version has the TFS features already installed. One ways to make sure of that is to check it out on several locations as follow:

-        After running Visual Studio, click on “VIEW” on the upper part of the window. If TFS is installed, you should see on the option list “Team Explorer”.

Capture01

Note: the “Team Explorer” panel on left hand side is very important because we are going to use it a lot to switch between TFS (Team explorer) and the projects (Solution explorer).    

-        After you making sure you the TFS, install GitExtensions packages. You can download on following link: http://visualstudiogallery.msdn.microsoft.com/abafc7d6-dcaa-40f4-8a5e-d6724bdb980c

 2 – TEAM FOUNDATION SERVER CONFIGURATION

-        Now you have the GIT installed in your computer, you must configure the GIT to connect to your visual studio cloud where the project are stored and shared among all team members. To do so, open your visual studio. Click on “VIEW” à “Team explorer”. Should the below Team Explorer – Connect window appear where “Team foundation Service” and “Local Git Repository” are empty.

-        Now from there, what you need to do is to click on “Configure Team Projects …” and the below window “”

  Capture02

-        On Image3 window, click on “Servers…”

 Capture03

-        On the Image4 window, click on “Add …”

 Capture04

-        On Image5 window, add your team foundation server on “Name or URL of Team Foundation Server” and click on “OK” to validate.

 Capture05

-        Once you click on “ok” on image5, the image4 will return, populated with the server name entered previously. If the name is correct, click “close” on image4

-        Once you close image4, image3 will return, populated with all projects in the server in the image left hand side. From there, just tick on the project you are involved in and click on “Connect”

 Capture06

-        Once you are connected on the server, you should see details about the project you have chosen, appear on the “Team foundation Service” section of your “Team explorer – Connect” window (image2).

 Capture07

-        Now you have your project in image2, they (it) should be cloned in your local repository for you to work on it. The cloning can be done in two different ways:

-        METHOD_1: After you the project are added into image2 “Team foundation Service” a yellow notification will appear on the top of the window, asking you to clone the project (the project name pointing is right after the “connect”) in your local repository. just click on the “Clone ” and two textboxes will appear on the “Local Git repositories” filled automatically with the full path of the project on the server for the first, and a default full path of the directory where the your project local repository will be hosted (you can changed it as you like).

So if the information provided on textboxes are correct accordingly, just click on “Clone” right below the textboxes.

Capture08

Beside the currently connected project, you can also connect to other project and clone them to your local repository by a right click on project, then click on connect

 Capture09

Once you are connected to the project, just click on the “Clone” under “Changes” section or the yellow notification on the top of the panel and proceed as previously with the text-boxes.

 Capture10

-        METHOD_2: in the second method, just click on the “Clone” right below the “Local Git Repositories” Section and the same two text-boxes like the METHOD_A will appear. But this u will have to only default full path on local of your local repository is filled up and you will have to fill up the full the project path on your server.

Capture11

Note: it is recommended to use the METHOD_1 which is mistake free for the project path as it is automatically filled. But in case the yellow notification doesn’t show up, use METHOD_2.

Now that your project is cloned project, you are good to work on it on your computer with or without internet connection.

3 – GIT OPERATIONS

The main Git usages are based on three operations which are commit, push and pull.

 3.1 – Commit Operation

Commit is basically saving all modification done on the project in your local repository.

-        Every time you working on the project or after each modification performed, you will need commit the solution (on the solution explorer) by doing a right click on the main project solution –> click on “Commit”

 Capture12

-        When you click on “commit”, will be redirected on the Team Explorer to write a message on the specified text-box and to click on “commit” to commit the solution. After the commit is completed, it will appear on the “Team Explorer – Commit” panel on “Outgoing Commits” section.

Capture13

Capture14

To perform an error-free commit, you need make sure about few things:

-        First, you need to make sure that all the changes made in the project are saved and none of the project files are being used by any other program. If you have databases in your project, make sure that their connections are closed.

Case: here below on image12, is an example on how to close a database. Go to VIEW –> Server Explorer. On “Server Explorer” panel click on “Data Connections” to see all databases created on your project. If the database icon is shown in green, that would mean that it connected and running, so it should close by a right click on it and click on “Close Connection”. After you have closed all opened databases, retry the normal commit steps

 Capture15

3.2 – Pull Operation

The pull operation is meant to fetch updated of the project from the server and merge it with the one currently available on your local repository. With the pulling function, the local on your local repository will be updated with the latest changes made by our team members.

To pull the latest project’s update from the server you need to make sure of the followings:

-        All files and databases of your local repository are not running or being used by a process.

-        Your project solution is committed and no more change is made after the commit

The those requirements are satisfied, go to your “Team Explorer – Connect” –> double click on your project name, you were working on, located in theTeam Foundation Service –> click on “Commit” under “Changes” section –> from here you click on “fetch” first, to retrieve new updates from the server –> then you click on “Pull” to merge it with your local repository.

 Capture16

 Capture17  

Note: here are examples of few pull error that you might encounter:

-        A pull operator might end up with a yellow notification message error when the databases on your local repository are running our being used by another program. Also an error might be raise when the latest changes of your local repository are not committed. Those problems can be fixed by closing the connection of the databases, commit your solution and run pull again.

Capture18

Capture19

-        Another type of error, merging conflict error, might arise during the pull operation. This type of error happened because some of project files are binary files. Binary files like databases cannot be compare by GIT therefore cannot be merged and would generate conflict after the pull operation. One the solution to resolve this conflict is to choose either to keep source file (and delete the one from the server) or to keep the remote one (and delete the one from your local repository).

In this case, it is recommended to keep the remote or target file. Unless one of your team members notified you that he has made a wrong update in the file in conflict, it is always better to better keep the files from the server when conflicts arise because the server is supposed to contain latest modification and updates.

 To resolve a merging conflict error, click on “Resolve conflicts” on yellow notification when conflicts arise.

NOTE: when window pops up asking you to whether to reload or not, click on “Ignore all”

Capture20

On the “Team Explorer – Resolve Conflicts” panel, you will see all the project files involved in conflicts on the “Conflicts” Section and all the merged files on “Resolve” section. You will notice that most of the files involve in conflicts are binary files and cannot be compared or merge by GIT (.mdf, .dll, .pbd). As explained earlier, the options for us here are either to choose either to keep files version from the local repository or the one from the server and in our case in chose the one from server because of the reasons explained earlier.

Now to save keep those files, click on one of them –> then you click on keep source–> and finally on merge. Repeat these action until there is no more files involved in conflicts (appearing in the conflicts section), then click on the “Commit Merge”.

  Capture21

 After clicking on the commit merge, you will be redirected to the “Team Explorer changes” panel asking to write a message and then click on “Commit”. From there, you are good to go once the commit is successful.

 Capture22

3.3 – Push Operation

Push operation is meant to update the project from the server by uploading changes made from your local repository to the server.

To perform a push operation you will need to make sure of the followings:

-        Make sure that there is no new update for you to fetch and pull from the server. Otherwise an error notification will be generated, asking you fetch and pull them.

-        Make sure that your databases (if there is any) are closed, and your solution is committed.

Then after you commit your solution, just click on “View Commits”. There, all your commits will be listed on the “Outgoing Commits” of the “Team Explorer – Commit” panel. Now all you will have to do is to click on “Push” to upload all your changes to the server.

  Capture23

Capture24

 

here below is attached the PDF version of the guide

GIT step-by-step guide

ENJOY !!!

About these ads

One thought on “Step-by-step guide on how to install and use Git on with Team Foundation Server (TFS)

  1. Stacia

    Itts like you redad myy thoughts! Yoou seem to uunderstand a lot approximaately this,
    such ass yyou wrotee tthe book in iit or something. I belpieve that
    yoou jhst caan ddo witth some percen tto drive the message huse a bit, bbut iinstead of that,
    tgis iss magnificeent blog. An exellent read. I’ll definitely be back.

    Reply

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