Git is a widely used version control system, and it’s essential to have it installed and configured properly for managing code repositories. Below is a step-by-step guide to installing Git and performing basic configuration.
For Windows
Download Git for Windows:
- Go to the official Git website.
- Download the Git installer (
.exe
file).
Run the Installer:
- Double-click the
.exe
file to run the installer. - Follow the installation prompts. You can choose the default options, which will work for most users.
- During installation, make sure the option "Use Git from the command line and also from 3rd-party software" is selected.
- Double-click the
Verify Installation:
After installation, open Git Bash or Command Prompt and type
git --version
This should show the installed version of Git, confirming it's installed correctly.
For macOS
Install via Homebrew (recommended):
First, install Homebrew if you don’t have it.
Open Terminal and run:
brew install git
Verify Installation:
Run the following command in Terminal to verify Git is installed:
git --version
Alternative (Xcode):
You can also install Git by installing Xcode Command Line Tools.
Run this in Terminal:
xcode-select --install
For Linux (Debian/Ubuntu)
Use the package manager to install Git:
sudo apt update sudo apt install git
- Verify Installation:
git --version
Basic Git Configuration
Once Git is installed, you need to configure it with your username and email. This information will be associated with your Git commits.
Set Your Username
git config --global user.name "Your Name"
Replace "Your Name"
with your actual name.
Set Your Email
git config --global user.email "your.email@example.com"
Replace "your.email@example.com"
with your email address.
Verify Configuration
To check if your configurations have been set correctly, run:
git config --global --list
This will display your global configurations, such as your username and email.