Using Git in Visual Studio has never been easier than in Visual Studio 2019
Visual Studio 2019 has many fantastic new features. Some of these features like the new start window make the use of Git in Visual Studio 2019 way easier than in the previous versions. Do you want to learn how to use Git in Visual Studio 2019?
Check out my new Pluralsight course
In my new Pluralsight course Using Git for Source Control in Visual Studio 2019, you will learn how to use Git in Visual Studio 2019 while working on a .NET application in the context of a small team.
My course is part of a Visual Studio 2019 course path at Pluralsight. Check out that course path to learn how to use Visual Studio 2019 successfully and efficiently in your projects. Also take a look at this Blog post from David Berry (Technical Curriculum Manager for .NET at Pluralsight) where you find also a bit more information about the upcoming Visual Studio 2019 courses.
In my course you’ll learn how Julia and I use Git to build a .NET Core application for the Wired Brain Coffee company. We will store our code in a Git Repository in Azure DevOps. The scenario looks like this:
The major topics that we will cover include:
- Creating and cloning Git repositories
- Committing and synchronizing changes
- Working with branches and tags
- Handling pull requests
- Viewing the history of your code
Before you start, you should know the Git basics, but as the course uses a scenario to build the so-called Wired Brain Coffee Shop Info Tool, you should be able to follow along, even without any prior Git knowledge.
The Shop Info Tool that we build is a .NET Core Console app that allows the Wired Brain Coffee company to see how many kilograms of coffee beans and how many paper cups a specific coffee shop has in stock.
While building this tool, you’ll learn how to use Git in Visual Studio 2019.
What’s new for Git in Visual Studio 2019
When you start Visual Studio 2019, you’ll see the new start window.
From this new start window you can
- Open a recent solution
- Clone a Git repository from GitHub, Azure DevOps, or any other Git service
- Open a project or solution
- Open a folder
- Create a new project
- Continue without code
This means directly after starting up Visual Studio 2019 you can clone a Git repository. That’s really nice. In previous versions of Visual Studio, you had to open up Visual Studio, you had to navigate to Team Explorer, and there you had to navigate to the Connect page to clone a Git repo. While this path still works in Visual Studio 2019, Visual Studio 2019 makes it much simpler to clone a Git repository directly after you started Visual Studio, because now you can use the new start window to clone a Git repo.
Beside the new start window Visual Studio 2019 contains other great features to work with Git. For example, with the “Pull Requests for Visual Studio” extension, you can create, review, comment, and approve pull requests directly in Visual Studio 2019.
The following screenshot shows a pull request comment from Julia and me directly in the code editor. You can also see the pull request details in Team Explorer. Julia just approved that pull request directly in Visual Studio:
Beside these new features – using the new start window and handling pull requests in Visual Studio 2019 – you’ll learn in my course everything you need to work successfully with Git and Visual Studio 2019. You’ll even learn the differences between a merge and a rebase, and of course we do both in Visual Studio to update a feature branch with the latest changes from master. :)
Happy coding,
Thomas
Comments (10)
Does the pull request feature work with self hosted tfs or only github?
Hi Mladen,
great question. So far, the “Pull Requests for Visual Studio” extension supports Azure Repos (= Git Repositories hosted in Azure DevOps). If you’re using GitHub, you might want to install the “GitHub extension for Visual Studio” that you find here: visualstudio.github.com.
For Self hosted TFS, which is called these days Azure DevOps Server, the “Pull Requests for Visual Studio” extension has no support right now. You find this information here under “known issues” at the bottom: https://marketplace.visualstudio.com/items?itemName=VSIDEVersionControlMSFT.pr4vs.
As it is a known issue, this might change in the future, so that the extension also supports Azure DevOps Server. But so far, nothing is known if and when Azure DevOps Server will be supported.
I hope this helps.
Thanks,
Thomas
I have already installed GitHub extension for Visual Studio” but still I can’t able to add the branches and reviewers
Hi Sneha, do you have a screenshot that shows your problem?
Can I see the file differences between versions?
Yes, of course you can. After applying the stash, you can do a diff
I need a branch to a previous version that appears in history. If I right-click a previous version and click Revert, does the highlighted version become the current version or am I reverting the highlighted version to something else?
Git is completely confusing and tends to describe vague operations in terms of ambiguous commands.
Hi Doug,
you can just right-click and instead of selecting “Revert” you select “Create branch”. Then you’ll get a branch that starts from that commit that you right-clicked.
Git is a graph of commits, and you can point a branch just to a commit.
Does this help?
Best,
Thomas
I am unable to see the difference of .aspx files in pull request. Can you help me in this?
Hi Nishant,
sure, I can help you. An .aspx file is not different from any other file. Can you show me the Pull Request or the repository?
Cheers,
Thomas