Hands-on demo – Working with Git locally and Azure DevOps integration using Visual Studio Code
In this demo, we will walk through the process of setting up a local Git repository, committing code changes locally, and pushing those changes to a remote repository on Azure DevOps.
1. Installing Git
Before starting, ensure Git is installed on your machine.
xxxxxxxxxx
11git --version
If Git is not installed, download and install it from Git's official website.
2. Setting Up Development Environment with Visual Studio Code
Install Visual Studio Code (VS Code):
Download and install Visual Studio Code from here.
Install Git Extension in VS Code:
Open VS Code.
Navigate to the Extensions view (
Ctrl+Shift+X
).Search for "Git" and install following two Git extensions.
Git Lens and Git History
3. Creating a New Git Repository Locally
Navigate to the Project Directory:
xxxxxxxxxx
11cd path/to/your/project
Initialize a New Git Repository:
xxxxxxxxxx
11git init
This initializes a new Git repository in the current directory.
4. Committing Code Changes Locally
Make Changes to files (e.g., add a new
README.md
file or modify existing code).Check the status of changes:
xxxxxxxxxx
11git status
Add files to staging:
xxxxxxxxxx
11git add README.md
Commit changes:
xxxxxxxxxx
11git commit -m "Added README file with project description"
5. Pushing Changes to Remote Repository on Azure DevOps
Create a New Repository on Azure DevOps:
Navigate to Azure DevOps.
Create a new project and repository.
Link Local Repository to Remote Repository: In Visual Studio Code:
Open the Command Palette (
Ctrl+Shift+P
).Type and select Git: Clone Repository.
Enter the URL of your Azure DevOps repository.
Push Changes to Remote Repository:
xxxxxxxxxx
21git remote add origin https://dev.azure.com/<yourorganization>/<yourproject>/_git/<yourrepository>
2git push origin main
This pushes the local commits to the Azure DevOps repository.
6. Verifying Changes on Azure DevOps
Navigate to the Azure DevOps repository to view the pushed changes.
Summary
This process sets up a basic workflow for managing code changes locally and pushing them to a remote repository on Azure DevOps using Visual Studio Code.
Leave a Reply