Git is a powerful distributed version control system widely used for source code management and collaboration. To begin using Git, you need to install and configure it on your operating system. Below is a step-by-step guide on how to install Git on Windows, macOS, and Linux, along with initial configuration.
Installing Git on Windows
- Visit the official Git website at https://git-scm.com.
- Download the appropriate Git version for your Windows operating system.
- Run the downloaded installer file and follow the on-screen instructions to complete the installation process.
- Once installed, open Command Prompt or PowerShell and verify that Git is installed successfully by running the command:
git --version
.
Installing Git on macOS
- Git can be installed on macOS using Homebrew. If you don't have Homebrew, visit the official Homebrew website at https://brew.sh and follow the instructions to install it.
- Open Terminal and run the command:
brew install git
. - After installation, verify that Git is installed successfully by running the command:
git --version
.
Installing Git on Linux
1. On most Linux distributions, you can install Git using the system's package manager.
-
Ubuntu or Debian: Open Terminal and run the command:
sudo apt-get install git
. -
Fedora: Open Terminal and run the command:
sudo dnf install git
. -
CentOS or RHEL: Open Terminal and run the command:
sudo yum install git
.
2. After installation, verify that Git is installed successfully by running the command: git --version
.
Once Git is installed, you need to set up initial configuration to identify your name and email address in Git. This is necessary for accurately recording your changes in commit history. Using Terminal or Command Prompt, run the following commands and replace your information:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
With these installation and initial configuration steps, you are ready to use Git on your operating system. You can now create and manage repositories, make changes, merge branches, and more.