How to – Perform basic Git operations with Visual Studio 2019


In the previous post,

https://nishantrana.me/2019/10/21/getting-started-with-git-repository-in-visual-studio-2019/

we learned how to setup and  get started with Git Repository in Visual Studio 2019.

In this post, we will learn how to perform some of the basic operations like commit, push, fetch, pull, etc. and how to merge the conflicts.

Let us open the solution created in the last post and make some changes

Here we have updated Program.cs and added a new class file Helper.cs


To commit these changes, we can either go to Team Explorer – Home – Changes page or click on the edit icon in the status bar of the Visual Studio.

After we have added our commit comments, we are presented with 3 different options

Commit All Commit will make a record of the changes in the local repository.
Commit All and Push Commit the changes locally and push the changes to the remote repository.
Commit All and Sync Commit the changes locally, fetch the changes from the remote repository and finally push the changes to the remote repository

We can also use the Stage option to break the commit into smaller stages

We will be presented with similar options for Commit Staged as in the case of Commit.

Perform Commit Staged and Push for both the changes.

We can see both the updates in our remote git repository

Other developers or team members who need to work in the project can Clone the project in Visual Studio 2019.

Provide the Repository location URL along with the local path.

Now suppose the developer 1 makes the below changes to the program.cs and does commit all and push.

The other developer 2, can click on Fetch in the Synchronization page to see any incoming commits.

Clicking on the commit shows the details of the changes as shown below.

Developer 2 can click on Pull to merge commits to the local master branch.

fetch Download the changes from remote repository
merge Applies the changes fetched to a branch in the local repository
pull fetch + merge

Now suppose developer 1 has changed the message and commit + push the changes to the remote repository.

And also, in parallel developer 2 has also updated the same message and has clicked on Commit and Push.

As both have made changes and referencing to the same line of code, the developer 2 gets the failure message when he tries to push his changes to the remote repository.

Message in the output window à

Developer 2 here can click on Fetch to see the changes

Developer 2 clicks on Pull to merge the changes and can see the conflict.

Clicking on Conflicts gives Developer 2 the option to Merge, Take Remote or Keep Local the changes.

Selecting the Merge option allows developer 2 the option to specify the merge.

Clicking on Commit Merge to merge the changes, followed by appropriate Commit operation to push the changes to the repository.


This resolves the conflict.

Thus, in this post, we learned how to perform basic operations like Push, Pull, Fetch, etc. and how to merge and resolve the conflicts using Visual Studio 2019.

Hope it helps..

Advertisements

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

2 thoughts on “How to – Perform basic Git operations with Visual Studio 2019”

Please share your thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Power Spark

Power Spark By Shrangarika

Van Carl Nguyen

Exploration of Power Platform

My Trial

It is my experience timeline.

Power⚡Thomas

Sharing my knowledge and experience about the Microsoft Power Platform.

Arpit Power Guide

a guide to powering up community

Welcome to the Blog of Paul Andrew

Sponsored by Cloud Formations Ltd

Deriving Dynamics 365

Deriving Solutions and features on Power Platform/Dynamics 365

The CRM Ninja

Thoughts & musings from a Dynamics 365 Ninja!

D CRM Explorer

Learn about Microsoft Dynamics CRM Power Platform customization and implementation and other cool stuffs

Stroke // Jonas Rapp

I know pre-stroke. I will improve who I was.

Power Melange

Power Melange By Shalinee

Clavin's Blog

Power Automate - Power Apps - SharePoint Online - Azure - Nintex - K2 - Artificial Intelligence

Sat Sangha Salon

An Inquiry in Being

The Indoencers

The Influencers & Influences of Indian Music

Monika Halan's blog

Hand's-free money management

D365 Demystified

A closer look at Microsoft Dynamics 365.

Microsoft Mate (msftmate) - Andrew Rogers

Experienced consultant primarily focused on Microsoft Dynamics 365 and the Power Platform

Knowhere365

Specific topics by Django Lohn on the whole Microsoft365 Stack

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions

MG

Naturally Curious

Brian Illand

Power Platform and Dynamics 365

Steve Mordue MVP

A Microsoft Business Applications MVP

Subwoofer 101

Bass defines your home theater

SQLTwins by Nakul Vachhrajani

SQL Server tips and experiences dedicated to my twin daughters.

Everything D365

Discovering Azure DevOps and D365 Business Applications

Tech Wizard

Lets do IT Spells

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM

CRM TIPS BY PRM

Mail to crmtipsbyprm@gmail.com for queries and suggestions

nijos.dev

Giving back to the community what I have learned

xrm CRM Dynamics

Dynamics CRM Technical & Functional Info

Dynamics 365 Blogs - Explained in unique way

Sometimes you need to look at things from different perspective.

CRM Keeper

Dynamics 365 Customer Engagement, CRM, Microsoft CRM, Dynamics CRM