Open Source Guide

Setup Git

Install and configure Git on your computer - step by step

Setup Git on Your Computer

Let's install Git and get you ready to contribute! Don't worry - we'll go through this step by step.

What is Git?

Git is a tool that helps you track changes in your code. Think of it like a "save game" feature for your projects - you can save your progress and go back to any previous version!


🖥️ Choose Your Operating System

Click on your computer's operating system below:


Windows Windows Installation

Download Git for Windows

  1. Go to git-scm.com/download/win
  2. The download should start automatically
  3. If not, click "Click here to download manually"

File Size

The file is about 50 MB. It should download in a few minutes.

Run the Installer

  1. Find the downloaded file (usually in your Downloads folder)
  2. Double-click Git-2.x.x-64-bit.exe
  3. Click "Yes" if Windows asks for permission

Installation Wizard

Follow these steps in the installer:

Screen 1: License

  • Click "Next"

Screen 2: Installation Location

  • Keep the default location
  • Click "Next"

Screen 3: Components

  • Keep all checkboxes as they are
  • Click "Next"

Screen 4: Start Menu Folder

  • Keep the default
  • Click "Next"

Screen 5: Default Editor

  • Choose "Use Visual Studio Code" (if you have it)
  • Or keep "Use Vim" (we'll change this later)
  • Click "Next"

Screen 6-10: Other Settings

  • Keep all defaults
  • Click "Next" for each screen

Final Screen

  • Click "Install"
  • Wait for installation (takes 1-2 minutes)
  • Click "Finish"

Verify Installation

  1. Press Windows Key + R
  2. Type cmd and press Enter
  3. In the black window, type:
    git --version
  4. You should see something like: git version 2.42.0

Success!

If you see a version number, Git is installed correctly! 🎉


macOS macOS Installation

Check if Git is Already Installed

  1. Open "Terminal" (press Cmd + Space, type "Terminal", press Enter)
  2. Type this command and press Enter:
    git --version

If you see a version number:

If you see "command not found":

  • Continue with the installation below

First, install Homebrew if you don't have it:

  1. Open Terminal
  2. Copy and paste this command:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Press Enter and follow the prompts
  4. Enter your password when asked (you won't see it typing - that's normal!)

Then install Git:

brew install git

Alternative: Install from Website

If you don't want to use Homebrew:

  1. Go to git-scm.com/download/mac
  2. Download the installer
  3. Open the downloaded .dmg file
  4. Follow the installation wizard

Verify Installation

In Terminal, type:

git --version

You should see something like: git version 2.42.0


Linux Linux Installation

Check if Git is Already Installed

Open Terminal and type:

git --version

If you see a version number, Git is already installed! Skip to Configure Git

Install Git

Choose your Linux distribution:

Ubuntu / Debian:

sudo apt update
sudo apt install git

Fedora:

sudo dnf install git

Arch Linux:

sudo pacman -S git

openSUSE:

sudo zypper install git

Verify Installation

git --version

⚙️ Configure Git

Now let's tell Git who you are. This information will appear on your contributions.

Set Your Name

Open Terminal (or Command Prompt on Windows) and type:

git config --global user.name "Your Name"

Replace "Your Name" with your actual name!

Example:

git config --global user.name "Emma Johnson"

Set Your Email

git config --global user.email "your.email@example.com"

Use the same email you used for GitHub!

Example:

git config --global user.email "emma.johnson@gmail.com"

Important

Use the same email address you used to sign up for GitHub. This connects your commits to your GitHub account!

Set Default Branch Name

git config --global init.defaultBranch main

This sets "main" as the default branch name (GitHub's standard).

Set Default Editor (Optional)

If you have VS Code installed:

git config --global core.editor "code --wait"

If you have Nano (simpler):

git config --global core.editor "nano"

Verify Your Configuration

Check that everything is set correctly:

git config --list

You should see your name and email in the output.


🔐 Connect Git to GitHub

Now let's connect your computer to your GitHub account using SSH keys (a secure way to authenticate).

What are SSH Keys?

SSH keys are like a special password that proves your computer is allowed to access your GitHub account. It's more secure than typing your password every time!

Check for Existing SSH Keys

ls -al ~/.ssh

If you see files named id_rsa.pub or id_ed25519.pub, you already have SSH keys! Skip to step 3.

Generate New SSH Key

Copy and paste this command (replace the email with yours):

ssh-keygen -t ed25519 -C "your.email@example.com"

When prompted:

  • "Enter file to save the key": Just press Enter (use default)
  • "Enter passphrase": Press Enter (no passphrase) or type a password
  • "Enter same passphrase again": Press Enter again or retype password

Created!

You should see a message saying "Your public key has been saved"

Copy Your SSH Key

On macOS:

pbcopy < ~/.ssh/id_ed25519.pub

On Linux:

cat ~/.ssh/id_ed25519.pub

Then select and copy the output (Ctrl+Shift+C)

On Windows:

clip < ~/.ssh/id_ed25519.pub

Add SSH Key to GitHub

  1. Go to github.com and log in
  2. Click your profile picture (top right)
  3. Click "Settings"
  4. Click "SSH and GPG keys" (left sidebar)
  5. Click "New SSH key" (green button)
  6. Give it a title (like "My Laptop")
  7. Paste your key in the "Key" field
  8. Click "Add SSH key"

Test the Connection

ssh -T git@github.com

You might see a warning about authenticity. Type yes and press Enter.

Success looks like:

Hi YourUsername! You've successfully authenticated...

🎉 You're All Set!

Congratulations!

Git is installed and configured! You're ready to start contributing to open source!

What You've Accomplished

✅ Installed Git on your computer
✅ Configured your name and email
✅ Connected to GitHub with SSH
✅ Ready to make your first contribution!


🆘 Troubleshooting

"git: command not found"

Solution:

  • Make sure Git is installed
  • Restart your terminal
  • On Windows, make sure you're using Git Bash

"Permission denied (publickey)"

Solution:

  • Make sure you copied the entire SSH key
  • Check that you added it to GitHub correctly
  • Try generating a new SSH key

"Could not resolve hostname github.com"

Solution:

  • Check your internet connection
  • Try again in a few minutes
  • Check if GitHub is down: githubstatus.com

Still Having Issues?


📚 Useful Git Commands

Here are some commands you'll use often:

# Check Git version
git --version

# See your configuration
git config --list

# Get help
git help

# Clone a repository
git clone <url>

# Check status
git status

# Add files
git add .

# Commit changes
git commit -m "Your message"

# Push to GitHub
git push

# Pull latest changes
git pull

Don't Memorize!

You don't need to memorize these now. We'll explain each command when you need it!


Next Steps


🎊 Great job setting up Git! You're one step closer to your first contribution!

Your Progress

0/12
0%