
Some time ago, the article "
Integrating Team Foundation Services with Git and other new features " was published. We were very pleased that the readers showed a keen interest in it and sent us feedback and questions. We will consider them in the process of improving our tools and services, so stay tuned for our news. In this post, I would like to tell you how developers can start using Git tools in Visual Studio and the Git service in TFS.
Before we get started, let's recall the key points identified by Brian Harry:
Deploying to the client and server is a standard Git application. The client works with almost any Git repository: local, corporate, Codeplex, GitHub, BitBucket ... The TFS service supports almost any Git client: the Git command line utilities, Xcode, Eclipse Git support service ... This is the basic principle outlined on day one. This is not about synchronization, but about providing full and compatible Git features.
The flexibility of Visual Studio allows you to work with exactly what you need: a local service, a TFS service, or third-party providers.
In order for you to work with Git in Visual Studio 2012, you need to install
Visual Studio Tools for Git .
')
Creating new local repositories
One of the main advantages of Git is the ability to perform many tasks locally. Visual Studio provides several convenient ways to create a local repository:
- Creating an empty local repository
- Creating a new solution in the local Git version control repository
- Placing an existing solution in the local Git version control repository
Creating an empty local repository
So, you need to create an empty local repository. In Visual Studio, this can be done in a matter of seconds.
Go to the Connect page and create a new repository.

Open the repository. In the command browser, it will be set as active.

Commit to the .gitattributes and .gitignore files created by Visual Studio. These files are necessary for Git to work properly in Visual Studio.


The new local git repository is ready!

Now it can be published, and all members of the working group will be able to use it.
Creating a new solution in the local repository
A new code project can be placed in the local repository of the Git version control system.

This option is most fully discussed in the guide on the Welcome Portal.
Placing an existing solution in the local Git version control repository
If you have a solution with which you work on the local computer, you can place it in a simple local repository of the Git version control system.


The repository is created. It remains only to make the files.

Adding an existing local repository
You may have several repositories that you use with other client tools. Regardless of whether there is remote access to the local repository, you can add it to Visual Studio: either a separate repository or all repositories from the specified directory (see the example below).

After adding the repository, open it and start working in Visual Studio.

By the way, did you notice the useful Open in Command Prompt command (Open on the command line)? You may need it for specific tasks. If the command line tools are not yet installed, you can do it now:

Cloning a remote Git repository to a developer’s computer
It doesn't matter where the Git repository is located - in TFS, CodePlex, GitHub, Bitbucket or another place. Visual Studio will allow you to work with this repository. To begin collaborating on code in a remote repository, clone the code onto your computer.
Cloning a Git TFS Repository to a Developer's Computer
If you are embarking on a new Git team project or simply setting up a computer for this, you need to clone the project to a computer anyway.

Cloning a third-party Git repository to a developer’s computer
Does the workgroup store part of the code in GitHub or another service (for example, CodePlex or Bitbucket)? It is possible to clone the code to a local computer and work with it in Visual Studio.

Publish local repository
If you want to share with other members of the workgroup part of the code stored on the local computer, publish the appropriate branch in the remote repository.
TFS Publishing
In addition, the code can be published to Team Foundation Service.

Posting to a Third Party Service
The code branch can be published in a remote repository hosted by a third-party vendor, for example, in CodePlex, GitHub, or Bitbucket.

After publication
After publishing the branch, Visual Studio performs the following actions:
- Sets the local repository as remote.
- Sends the active branch (in most cases it is “Master”) to the remote repository.
Now you can work together with other members of the group: accept changes made by them or send your edits to a remote repository.
Connection Management
The Connect page is an innovation introduced in Visual Studio 2012 Update 2. This page shows and controls all the repositories in which version control is performed.

Right-click on the desired repository, and then select Open (Open) or another command.

Development Tool Articles
We remind you that you can learn more about the various aspects of Visual Studio features from the blog.
Developer Tools