Learn Git Clone, Commit, Sync And Push Changes Using Visual Studio

Introduction

In this article, we discuss how to perform Git operations i.e. Clone, Commit and Push using Visual Studio. It can be possible without writing a single command and It will save our time. In my previous articles, I already have described the Git operation using Git Bash. For that, we need to write commands to perform Git operations.

Today, I will describe the below-mentioned points in detail,

  1. Clone repo from remote GitHub repo using Visual studio
  2. Commit changes and check history using Visual studio
  3. Sync changes to staging area before push changes using Visual studio
  4. Push the changes to remote GitHub repo using Visual studio

Note
Before going through this session, please visit my below-mentioned sessions related to Git and GitHub,

  1. Introduction To Git
  2. Steps For Configuring Git With Details
  3. Let's Know About Git Add, Git Commit, Git Status, And Git Push-In Details
  4. Let's Understand How Git Maintains History Of Version Or Commit Ids With Details
  5. Steps To Initialize A Git Repository And Push The Changes To GitHub In Details
  6. Let's Know About Git Branches And How To Implement It
  7. Let's Understand About Git Branches And Its Real-Time Uses
  8. Let's Learn About Merging The Git Branches And Create Pull Request In Details
  9. Steps To Ignore Files Using Gitignore In Details
  10. Let's Learn About Git Default Branch In Detail
  11. Steps To Create And Configure Organizations In GitHub In Details
  12. Let's Learn About GitHub Projects In Detail
  13. Let's Know About Team In GitHub In Details
  14. Managing Files On GitHub In Real-Time - Owner Uploads Project In GitHub Repo
  15. Managing Files On GitHub Using Git Bash In Real-Time Scenario - Know About GitHub Reviewer
  16. Managing Files On GitHub Using Git Bash In Real-Time Scenario - Removing A Specific File From Pull Request

Clone repo from remote GitHub repo using Visual studio

Go to Team explorer of Visual Studio as shown below.

Then clone the repo from the GitHub repo as shown below.

Give clone repo URL as you copied and the path where you want to clone this repo in your PC.

You can see that It starts cloning the repo as shown below.

You can get clone status with details like path of clone repo and branch of that repo as shown below.

During clone, If it asks for GitHub authentication then give the user credentials and it will start cloning of repo from remote GitHub repo to your local directory.

After successful cloning that repo, You can get the cloned repo files in Visual Studio.

Also, you can see the repo of your local directory as you have given before cloning the repo as shown below.

Commit changes and check history using Visual studio

I want to add a new line of code in MyFile2.cs and check the status of that file as shown below.

Before commit and push changes you can see the history section of MyFile2.cs. There is no update in history.

Then commit those changes to that file as shown below. Right click of MyFile2.cs and click Commit option.

Then add the commit message for that changes to staging area as shown below.

Next, I commit those changes to staging area as shown below.

The commit message is updated in history section of Visual Studio as shown below. That means the changes have been committed to staging area.

This is committed to local repo or staging area but not committed to remote GitHub repo as shown below. If you check that MyFile2.cs in remote GitHub repo then you can't see that changes there.

Sync changes to staging area before push changes using Visual studio

Before push those changes the Visual Studio used a term called sync to share your changes with the server as shown below.

After click on sync option, We get the below interface with commit message details.

Push the changes to remote GitHub repo using Visual studio

Next, click the push option to update those changes in remote GitHub repo.

Now you can see a successful message after push those changes to remote GitHub repo.

Now you can see the remote GitHub repo with latest commit changes as shown below.

Finally, we can check the new property added to MyFile2.cs of remote GitHub repo as shown below.

Summary

In this write-up, we have learned the below details,

  1. Clone repo from remote GitHub repo using Visual studio
  2. Commit changes and check history using Visual studio
  3. Sync changes to staging area before push changes using Visual studio
  4. Push the changes to remote GitHub repo using Visual studio

Thank You & Stay Tuned For More