Visual Studio Code (VS Code) is one of the most popular code editors for developers, offering powerful features including built-in Git support. However, VS Code does not install Git by default. To enable version control and Git commands in VS Code, you must install Git separately on your system.
In this post, youโll learn how to install Git on your computer and configure it to work seamlessly with Visual Studio Code.
๐งฉ Why Do You Need Git for VS Code?
While VS Code supports Git-based workflows (such as staging, committing, and pushing changes), it depends on Git being installed on your system. Without it, Git-related features will be disabled in the Source Control tab.
โ Step-by-Step Guide to Install Git for VS Code
๐น Step 1: Download Git
Visit the official Git website:
๐ https://git-scm.com/downloads
The site will automatically detect your operating system and offer the correct installer.
๐น Step 2: Install Git
๐ธ For Windows:
- Download the
.exe
installer. - Run the installer and follow the setup wizard.
- Choose default options unless you have specific preferences.
- On the “Choose the default editor” screen, you can select Visual Studio Code if available.
- Complete the installation.
๐ธ For macOS:
Use Homebrew (recommended):
brew install git
Or download and install the .dmg
file from the Git website.
๐ธ For Linux:
Use your package manager:
- Ubuntu/Debian:
sudo apt update sudo apt install git
- Fedora:
sudo dnf install git
๐น Step 3: Verify Git Installation
Open a terminal (or Command Prompt on Windows) and run:
git --version
You should see something like:
git version 2.44.0
This confirms Git is installed and ready to use.
๐น Step 4: Configure Git
Set your Git identity so your commits are associated with the correct name and email:
git config --global user.name "Your Name"
git config --global user.email "yo*@ex*****.com"
๐น Step 5: Open Visual Studio Code
Now open VS Code. It should automatically detect Git.
- Click the Source Control icon (left sidebar) or press
Ctrl+Shift+G
. - If your folder is a Git repository, youโll see Git options like staging and committing.
If VS Code doesn’t detect Git:
- Restart VS Code
- Or set the Git path manually:
Open Settings (Ctrl + ,
) โ Search forgit.path
โ Set it to the path where Git is installed (e.g.,C:\Program Files\Git\bin\git.exe
).
๐ง Bonus Tip: Install the GitLens Extension
For enhanced Git features in VS Code, install GitLens:
- Go to the Extensions tab (
Ctrl+Shift+X
) - Search for GitLens
- Click Install
GitLens provides rich Git history, line blame annotations, and advanced repo insights.
โ Summary
Task | Action |
---|---|
Download Git | git-scm.com/downloads |
Verify installation | git --version |
Set Git user identity | git config --global user.name/email |
Use Git in VS Code | Open the Source Control panel |
Enhance with GitLens | Install via VS Code Extensions |
๐ Conclusion
By installing Git and connecting it with Visual Studio Code, you unlock a complete version control workflow right inside your editor. Whether you’re committing changes, managing branches, or pushing to GitHub, the integration between Git and VS Code makes your development process smoother and more efficient.