Step 6: Work with Git

Applies to: yesVisual Studio noVisual Studio for Mac noVisual Studio Code

Previous step: Install packages and manage your Python environment

Add Git source control

Now that you've created an app, you might want to add it to a Git repository. Visual Studio makes that process easy with Git tools you can use directly from the IDE.


Git is the most widely used modern version control system, so whether you're a professional developer or you're learning how to code, Git can be very useful. If you're new to Git, the website is a good place to start. There, you can find cheat sheets, a popular online book, and Git Basics videos.

To associate your code with Git, start by creating a new Git repository where your code is located:

  1. In the status bar at the bottom-right corner of Visual Studio, select Add to Source Control, and then select Git.

    Screenshot of the Git source control buttons below the Solution Explorer pane, with the Add to Source Control button highlighted.

  2. In the Create a Git repository dialog box, sign in to GitHub.

    Screenshot of the Create a Git Repository dialog window where you can sign in to GitHub.

    The repository name auto-populates based on your folder location. Your new repository is private by default, which means you're the only one who can access it.


    Whether your repository is public or private, it's best to have a remote backup of your code stored securely on GitHub. Even if you aren't working with a team, a remote repository makes your code available to you from any computer.

  3. Select Create and Push.

    After you create your repository, you see status details in the status bar.

    Screenshot of the repo status bar that's below the Solution Explorer pane in Visual Studio.

    The first icon with the arrows shows how many outgoing/incoming commits are in your current branch. You can use this icon to pull any incoming commits or push any outgoing commits. You can also choose to view these commits first. To do so, select the icon, and then select View Outgoing/Incoming.

    The second icon with the pencil shows the number of uncommitted changes to your code. You can select this icon to view those changes in the Git Changes window.

To learn more about how to use Git with your app, see the Visual Studio version control documentation.

Tutorial review

Congratulations on completing this tutorial on Python in Visual Studio. In this tutorial you've learned how to:

  • Create projects and view a project's contents.
  • Use the code editor and run a project.
  • Use the Interactive window to develop new code and easily copy that code into the editor.
  • Run a completed program in the Visual Studio debugger.
  • Install packages and manage Python environments.
  • Work with code in a Git repository.

From here, explore the Concepts and How-to guides, including the following articles: