Up and running with Git in Visual Studio [Video]

There are a lot of people who like to use Git with the command line, and you can certainly do that with your Visual Studio projects. As of this writing, there are hundreds, maybe thousands, of tutorials and videos showing you how to use the command line, but I have yet to find a simple video that walks you through the basics. For that reason, I am sharing this article and related video to help you get started.

What is Git?

Git is a VCS (version control system) and I discuss it in more detail in another article here on the TechGenix site. If you want to get a basic understanding and some history, I suggest you check out this article on Wikipedia.

Git lends itself really well to the distributed nature of software development. Developers from anywhere can work on their projects, share the code whenever they want, and not be locked because someone checked out some code from a far side of the world. Git is essentially a tool that enables collaboration and then provides the ability to check-in code with a review process that allows you to compare one source of code vs. another.

Video: Using Git in Visual Studio

Before you can use Git with your Visual Studio project, you need to know how to get it set up. When I turned to videos and articles online, nearly all the authors assumed you already configured Git. While it is very simple to configure your projects for Git, I want to make sure you know how to get it work.

In the following video, I use Visual Studio 2017 to show you the basics of getting Git set up on your local computer. If you are using Visual Studio 2015, the steps are fairly similar, but you may find a need to install additional components depending on what you already installed.

  • Create a new project that uses Git.
  • Migrate an existing project to a Git repository.
  • Clone a Git project from a remote Git repository.
  • Perform a basic sync and push between your local and remote Git repositories.

[tg_youtube video_id=”jUiuIAZt6Dw”]

When to start using Git

Frankly, if you want to manage the source for your code, you should start to use Git immediately. Since Git focuses on the differences between files, it is very lightweight. It is important to know that you do not have to purchase a service. You can just start a local project using Git on your computer and use it to track the changes to your project.

You can add your current project to a Git repository or start a new project from scratch and add it to a Git repository. If you are only using Git locally on your computer, you can always add it to a cloud-based source so your files are backed up.

How Git helps me

Before I started using Git, I would sit down and work on my code. I would fly around from one file to another, modifying things as I saw fit. Since I am the primary developer of the code, that method was not a problem, but once I shipped the software, I realized it would be incredibly hard to track changes and release new versions while still tweaking other bits of the product not ready for release.

Agile methodologies have you determine a set of requirements, often called user stories. You might also just have a list of tasks or issues to resolve. All those items are part of your backlog of work. By working on a backlog item as a small branch of the master project, you can test and validate your work. You can then submit a pull request so another developer or several developers reviews your work before it goes into the master. I do all these things now even as an individual contributor who owns the code. I like this approach because every task I complete is self-contained and I can revert to older versions if I royally screw something up.

Selecting a service

As I said earlier in this article, you can use Git on your computer alone, and that will add a lot of value. However, if you only use Git on your computer, what happens if something catastrophic occurs like the computer is stolen or the hard drive crashes? At some point, you will want a server-based solution. Two of the more popular server solutions are Microsoft’s Visual Studio Team Services and GitHub.

Git in Visual Studio

Visual Studio Team Services is a really nice solution if you want to create free repositories that are protected by default. For example, my software product is something I sell and it is not open source. If I want to protect my code, then I would have to pay a company to host Git for me. With Visual Studio Team Services, you can have up to five team members on your project at no cost. Microsoft also offers features like the ability to build your code in the cloud. Of course, Microsoft offers paid levels as well.

Do not confuse GitHub with Git. Git is an open-source application. GitHub is just like any other company that offers hosted Git repositories, but they are certainly the most popular. You can use GitHub for free, but your product will have to be open source. GitHub also offers pretty inexpensive pricing models for anyone who wants to host their private projects as well.

Create your Git workflow

Depending on the size, scope, and contributors to your project, you will need to design a Git workflow that works best for you. I do not prescribe any such workflow in this article. As a matter of fact, when you watch the video, I do enough to add a file, sync it with the server and then push it up to the remote Git service.

For further reading, I suggest you start by taking in the basics at GitHub’s training site and the Visual Studio Team Services site. These sites can get you on the right path and then you can start digging into the details of how you will manage your code. A simple search for Git workflow on Google will get you started.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top