Over a million developers have joined DZone.

Git Operations With Visual Studio

DZone 's Guide to

Git Operations With Visual Studio

If you're more inclined to using Visual Studio, check out how you can still use it for your version control with Git.

· Open Source Zone ·
Free Resource


Git is an open source version control system which keeps the source code and tracks the changes in it. Git is mainly used for source code management in software development, where we keep source code in the git repository/directory/branch and it gives centralized access to the team. Git also keeps track of changes. Git has a set of commands and git cmd is used to perform git operations, like create a repository in git, create a local copy of the repository, create branches, add files, commit the changes, push the changes to a remote repository, and many more. Here is the list of all the git operations.

Microsoft Visual Studio has a Git client built-in directly into the IDE. We can perform most of the source control operations on git from Visual Studio directly. Visual Studio 13 update 1 has great support with git.

Create a Repository

A git repository, also called a repo, is a folder on the git which is used to keep and track project files and changes. The new repository can be created while creating a new solution in VS, simply by selecting "Create new Git repository."

create repository by Arvind singh

We can also create a repository from an existing solution. Go to Team Explorer and click on the "Publish" button in the bottom. It will create a new Git repository and open a "Publish view" to push the code to the remote Git repository.

clone repository by arvind singhClone Remote Repository

To get the code from the git remote repository, we clone the git repository and initialize a local repository. Go to team explorer; there is a plug icon on the top. Click on the plug icon and select the repository. Enter the repository path, then click on the "Clone" button. It will clone the repository and download all the commits and branches in the local copy of the repository.

Image title

Now, we have a copy of the repository. Make changes to the branch in files and perform another git operation.

View Changed Files

To see the uncommitted changes and files, go to Team Explorer and click "Changes."

git view change files by arvind singh

Stage (Index) File

To stage (or index) uncommitted changes, select the file, enter the comment, and click "Stage."

git stage

Commit/Push Modifications

To Commit/Push, you need to put some text in the comment area before committing the changes.

You can choose from three options.


Actions performed

Commit Staged

Commit locally

Commit Staged + Push

Commit locally + Push to a remote repository

Commit Staged + Sync

Commit locally +

Pull (get updated info from a remote repository)

+ Push to a remote repository

git commit by visual studio by arvind singh


The committed files will disappear from the change list and the commit id will be displayed.

git commit result

Push Modifications

To push locals commits to a remote server, go to Team Explorer Synchronization and click "Push."

push modification

Stashing Code

Visual Studio does not support this feature for now. You have to either stash in the command line or with a third-party software (SourceTree, …) or you can install a VS extension.

Read here about Git stashing.

Change the Current Branch

Go to "Team Explorer" and click on the branches.

visual studio change git branch

You can change the current branch by double-clicking on the branch (All the files are instantly updated).

git change branch

But if you still have modified files in the current branch, you cannot change the branch first. You have to commit, stash, or cancel the modifications.

git branch change

Your recently used branches are available in the bottom shortcut of Visual Studio.

change branch result

Create a New Branch

To create a new branch, go to the Team Explorer, click on “New Branch,” and you will have to indicate

  • the branch name
  • and the branch to be used to create the new one.

If you want to, switch to the branch you create (“Checkout branch”, but not like the TFS meaning)

create branch


In this article, we have seen some basic Git operations which we can perform with Visual Studio. We also saw that there are some limitations, such as stashing, which is not possible yet with Visual Studio.

git ,visual studio ,version control ,tutorial ,open source ,git cli

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}