🧰 Git Installation Guide for Windows #
Follow the steps below to install and configure Git on the Windows operating system. 🚀
1. Downloading and Installing Git #
1.1 Download Git #
Download Git from the official website: 🔗 Git for Windows
-
It automatically detects your system architecture (32-bit or 64-bit) and starts the download.
-
Alternatively, if you’re using Chocolatey or Scoop:
choco install git
or
scoop install git
1.2 Install Git #
Run the downloaded Git-*.exe
file and follow the steps below:
-
Choose the installation directory: You can leave it as default:
C:\Program Files\Git
-
Installation options (recommended settings):
- Select Git Bash and Git GUI: Keep both.
- PATH environment: Choose
"Git from the command line and also from 3rd-party software"
(Allows usage in CMD, PowerShell, and other tools). - SSH executable:
Use OpenSSH
- Line endings: Keep
"Checkout Windows-style, commit Unix-style line endings"
selected. - Terminal emulator:
Use MinTTY
(orUse Windows default console
if you prefer CMD).
-
Start the installation and wait for it to complete.
2. Verifying Git Installation #
To confirm Git is installed correctly, open CMD, PowerShell, or Git Bash, and run:
git --version
If you see something like:
git version 2.42.0.windows.1
Git was installed successfully.
3. Configuring Git #
After installation, configure Git for your environment.
3.1 Set User Information #
Run the following in the terminal to set your user info:
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
Check the settings with:
git config --global --list
3.2 Generate SSH Key (for GitHub/GitLab) #
To connect without passwords to GitHub, GitLab, or Bitbucket, create an SSH key:
-
Generate an SSH key:
ssh-keygen -t ed25519 -C "email@example.com"
It will be saved by default at
~/.ssh/id_ed25519
. -
Add the key to GitHub:
clip < ~/.ssh/id_ed25519.pub
- Log in to GitHub → Settings → SSH Keys → New SSH Key → Paste → Save
-
Test the connection:
ssh -T git@github.com
A successful message looks like:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
4. Getting Started with Git #
4.1 Initialize a New Repository #
mkdir project
cd project
git init
4.2 Clone an Existing Repository #
Clone using HTTPS:
git clone https://github.com/username/project.git
Or using SSH:
git clone git@github.com:username/project.git
4.3 Common Git Commands #
Command | Description |
---|---|
git status |
Shows the current working status |
git add . |
Stages all changes |
git commit -m "message" |
Commits the staged changes |
git push origin main |
Pushes changes to the remote repo |
git pull origin main |
Pulls the latest changes from the repo |