Installing Visual Studio Code
Before installing Git, let's set up Visual Studio Code — a powerful code editor with excellent Git integration. Follow the instructions below for your operating system:
Windows, macOS and Linux
- Visit the official VS Code website: https://code.visualstudio.com/
- Click the download button for your operating system.
- Run the installer and follow the on-screen instructions.
- After installation, open Visual Studio Code to confirm it works correctly.
Visual Studio Code offers excellent Git integration, including:
- Visual diff of file changes
- Staging and committing changes directly from the UI
- Commit history viewer
- Merge conflict resolution
- GitHub and remote repository integration
Installing Git
Now that VS Code is ready, let's install Git. Follow the instructions for your operating system:
Git installation process demonstration
Windows
- Visit the official Git website: Git for Windows
- Download and run the installer.
- Follow the installer steps, keeping the default options.
- After installation, open VS Code, press Ctrl+` to open the integrated terminal and type
git --versionto verify the installation.
macOS
- Open the Terminal in VS Code (Ctrl+`).
- Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Install Git with Homebrew:
brew install git - Verify the installation by typing
git --versionin the VS Code terminal.
Linux (Ubuntu/Debian)
- Open the Terminal in VS Code (Ctrl+`).
- Update system packages:
sudo apt update - Install Git:
sudo apt install git - Verify the installation by typing
git --version.
Configuring Git in VS Code
After installing Git, VS Code will automatically detect it. To start using Git in VS Code:
- Open a project or folder in VS Code.
- Click the Source Control icon in the left sidebar (branch icon).
- Click "Initialize Repository" to start a new Git repository, or use Git commands directly in the integrated terminal.
You're now ready to use Git with Visual Studio Code!