[Go] How to use Git in TFS

Source: Internet
Author: User
Tags hosting git client how to use git using git version control system

This article turns from http://www.cnblogs.com/stg609/p/3651688.html

Charley Blog Code version control the idea of a long-standing, in the early days of the code was actually used to control TFS, but later did not use it well, coupled with the subsequent changes in the system environment caused by the loss of TFS connection, it is formally abandoned version control this important tool. After a few months, the last chance, after trying the Git tool to maintain "ueditor upload images to seven kn (CSharp version)" Of the code used, feel good, so there is the use of git to maintain Charley Blog's original impulse.

In this article, I'll explain in detail how to use Git to connect to TFS, so let's go ahead and see.

If you are lazy to read the text, you can also visit the following video website to watch: potatoes, Youku, 56.

Tfs

Team Foundation Server is a collaborative development tool provided by Microsoft that provides Application lifecycle management (alm,application Lifecycle Management) features, including work item creation, source control (TFVC, Team Foundation Version Control), test management, and so on, can effectively help teams collaborate on development.

About Git

Git is a distributed version control tool that developers can use to store code in a local code base or a code base (or code-hosting server) on a network. The more famous Git hosting servers are GitHub, Googlecode, BitBucket, CodePlex, and Microsoft's cloud TFS. Domestic has Gitcafe, Csdncode, open source China-code hosting.

In addition to Git, the version Control tool also has SVN (Subversion), VSS (Visual SourceSafe), TFVC, and so on.

In this article, the default reader has a basic understanding of Git, if not yet, we recommend reading reference resources [1], [2].

Using Git in TFS

Since January 30, 2013, TFS has been supporting the use of Git to check in the source code, which is a good news for many project groups. However, to use this feature, you must install a Visual Studio extension that supports only Visual Studio Update 2 or later (Visual Studio 2013 natively supports Git). [3] After installation, the development team can mix git and TFVC to check in code, or use other third-party git client tools or third-party git hosting servers. If you use TFS as your code hosting server, you can continue to use TFS's powerful application lifecycle management tools.

Below, I'll show you how to use Git to check in your code into TFS using an example.

1. Download the Visual Studio extension

Only TFS is displayed in Team Explorer before the extension is installed.

Select "Tools", "Extended Updates" to enter the following interface.

Enter "Git" in the input box

After the installation is complete, restart Visual Studio and you will find that the Team Explorer interface has more Git columns.

2. New Project

Select the console application and check Add to source control.

The first time you enter the project, you will be asked to choose the source control system you want, here we choose "Git".

When you finish selecting the source control system, Visual Studio will initially set up Git.

The project's Repository has been created successfully

At this point, we look at Solution Explorer and see that there are more source control status icons available before each project.

"+" means that the file is newly added

Right-clicking on each item will reveal three more new things in the context menu: Undo, View history, Commit. These are the shortcut menus for source code control.

3. Configure the Git Source Control tool

Open Team Explorer, which appears as follows:

"Prompt to install third-party command-line tools", currently not available, temporarily ignored

Click "Changes"

Team Explorer switches to the "Changes" interface, which lists all of the code that has been modified this time.

Before we formally check in the code, we also need to configure Git once, otherwise the "Commit" button will always be grayed out and cannot be clicked.

Click "Config" to go to the configuration interface, where you enter a user name, a mailbox, to display a check-in information in the history of the source code manager. When completed, click "Update".

The user name, mailbox is not the credentials to log on to TFS, but is used to identify a check-in person's code, you can fill in any. The above configuration can be modified at a later stage.

4. Project Check-in

Go back to the "Changes" screen, fill in the description of this check-in and click "Commit" to check in.

We have not connected any source-code hosting servers, so now check-in is only checked into the local code base. So you will find that the check-in is very fast, and after the check-in is successful, the following information is displayed.

Commit XXX created locally. Sync to share your changes with the server.

Click "Commit 77a04762" to see the details of this check-in.

Returning to Solution Explorer, the original "+" sign becomes a small lock, indicating that the file has been checked in successfully.

5. Modify the Code

Modify the code in the Program.cs, you will find that the small lock becomes a "hook", which means that the file has been modified locally.

Right-click Program.cs in Solution Explorer and choose Source Control, Compare with umodified to compare the differences between the current version and the previous version.

Select "Compare with Umodified"

The Compare panel

After checking in the changes, review the history.

The history panel

So far, our versioning operations on code are based only on the local code base and not on the servers on the network. This is a wonderful thing for a personal developer.

6. Synchronizing TFS servers to the cloud

6.1 Establishing a server using Visual Studio Online [6]

For small development teams of less than 5 people, you can use Visual Studio Online to maintain your code for free.

Enter "https://app.vssps.visualstudio.com/" in the browser to connect to Visual Studio online, and a Microsoft account can only create one Visual Studio online account.

Create a code base and select the source Control tool that will be used.

Create a new code base

Created successfully

Click the "Code" option in the top left corner to go to the "Code" page. The first time you enter this page, you will be prompted to connect to this code base. Copy the code base address.

6.2 Code synchronized to the newly created code base

Go back to Visual Studio and select "Unsynced commits" to paste the address you copied above into the right position.

Unsynced commits interface

Paste the address into the input box

Click "Publish" to start synchronizing data from the local code base to the server.

Click "Publish"

Commission success

7. View the code on the server side

When the data synchronization is successful, we can enter the server to view the code status.

Or go to the "Code" page, you can now see the code you just submitted.

Viewing the history, you can see that all local historical versions have been correctly synced to the server side.

Above, I just showed you how to add a new project to TFS in the cloud. You can add existing projects to the source control system, see reference resources [6].

Git and TFVC

TFVC

Centralized version-control system. Specifically, with this tool, all file version history data is only preserved on the server, and only one version of the file is retained on the developer's machine, and the historical data must be lifted from the server.

All version control operations on code must be connected to the server, unable to check in locally for code, create branches, compare historical versions, and so on.

The branch is path-based and is created only on the server.

Supports force checking when code is checked in, and TFS rejects check-in if a pre-defined specification is not met.

Supports pending modifications (that is, the shelve feature in VS2010, the suspend feature in vs2012), and continues at a later date.

Git

A distributed version control system that maintains a full version history on every developer's machine.

You do not need to be connected to code versioning, such as check-in, branch creation, and historical version comparisons.

The branch is lightweight and can be switched freely.

Forced checks are not supported when code is checked in.

See resources [5] for detailed differences.

Reference Resources

[1] Pro Git Chinese version

[2] Git-A concise guide

[3] Git init VS

[4] Use Visual Studio with Git

[5] using version control

[6] Connecting to Visual Studio Online

This article from Charley Blog

[Go] How to use Git in TFS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.