20th May 2022

Git in VS 2022

.NET

Written By, Dharvi Vithlani

Overview

Hello Devs, When we are thinking about a version control system, then the first thing that comes to our mind is Git. In this blog, we are going to discuss some cool features in Visual Studio 2022 version 17.1 and preview version 17.2.

Enable Preview Features of Git : 

For multiple repositories branching and line staging features we have to enable this feature.

From Tools   >  Options  >    Preview Features   >  then  Enable Features.

Preview Features

 New features of Git :

  1. Facilitates for branch comparison
  2. Checkout in the local or remote commits
  3.  Multiple-repositories branching
  4. Facility to commit a single line

1.  Facilitates for branch comparison :

In Previous versions, there is no  facility to directly compare branches but we can compare code.

In version 17.1 we can compare a branch with another branch.

So we can easily see in which branch what changes we made.

CompareBranch

2.  Checkout in the local or remote commits :

If we want to review committed code from a remote branch or local branch then it is possible in Visual Studio 2022 version 17.1.

We just right click on the history in which we want to checkout.

checkout

When we click on checkout then the following window opens and just click on Ok button to view the previous commit.

checkoutOKButton

3. Multiple-repositories branching 

In Visual Studio 2022 version 17.1 this feature is included.

This feature boosts collaboration and across different teams by enabling solutions to support projects hosted on different git repositories.

We can also commit the changes in multiple repositories. Just write a commit message and click on the commit all Repos button it will automatically commit changes into cross repositories.

At the same time Visual Studio 2022 will automatically activate up to 10 repositories.

MultiRepo

4. Facility to commit a single line

In Previous versions of Visual Studio we can’t commit or stage a single line.

In Preview version 17.2 we can stage or commit a single line of code.

If we are sure to commit a single line of code then they can easily do this.

In Git changes during comparing a file, we can stage a single line change like this…

StageLine

Conclusion

So, this blog provides information regarding what is new in Git and features that include more efficiency for code-level up. Hope from this blog you may get an understanding of previews and features.

Written By,

.NET Developer at Yudiz Solutions Pvt. Ltd