This article presents Step 6 in the tutorial series Work with Python in Visual Studio.
Git is a version control system that helps you keep track of changes to your code files and projects. By storing your Python project files in Git, you can enable multiple developers to contribute to your files and maintain the integrity of your project over time.
In the previous Steps in this tutorial, you create a Python application and make various changes to the code. In Step 6, you can add your application to a Git repository. You explore how to work with Git tools in Visual Studio to provide source control for your Python projects.
Although not required to proceed with this Step, review the instructions in Step 3, Step 4, and Step 5 of this tutorial for an end-to-end Python workflow in Visual Studio.
Add Git source control
Now that you have an application, 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.
Tip
Git is the most widely used modern version control system. 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 https://git-scm.com/ website is a good place to start. 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:
In the status bar at the bottom-right of Visual Studio, select Add to Source Control, and then select Git.
In the Create a Git repository dialog box, sign in to GitHub:
The repository name autopopulates based on your folder location. Your new repository is private by default, which means you're the only one who can access it.
Tip
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.
Select Create and Push. After you create your repository, you see status details in the status bar:
Use Git actions in Visual Studio
Here's a brief summary of Git actions available in the Visual Studio status bar:
The Up/Down arrows show 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.
To view a specific commit, select the Up/Down arrow, and then select View Outgoing/Incoming.
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.
Manage data ingestion and preparation, model training and deployment, and machine learning solution monitoring with Python, Azure Machine Learning and MLflow.