Course එකට ආපසු

Installing Git

20 මිනිත්තු🏋️Activity

Installing Git

Git is a version control system — software that tracks changes to your code over time.


What is Git?

The Problem Git Solves:

Text
Without version control:
my_project/
├── index.html
├── index_v2.html
├── index_v2_final.html
├── index_v2_final_REALLY_FINAL.html
├── index_backup_before_changes.html
├── index_old_dont_delete.html
└── 😱
With Git:
my_project/
└── index.html ← Always the current version
└── (Git remembers EVERY previous version automatically)

Git Is Like:

AnalogyHow It Relates
Unlimited UndoGo back to any previous version
Save GameCreate checkpoints you can return to
Time MachineTravel to any point in your project's history
InsuranceNever lose work again

Why Every Developer Uses Git

Reason 1: Safety Net

Made a mistake? Go back to when it worked.

Reason 2: Experimentation

Try crazy ideas. If they fail, undo. If they work, keep them.

Reason 3: Collaboration

Multiple people can work on the same project without conflicts.

Reason 4: Professional Requirement

Every tech company uses Git. It's not optional in the industry.

Reason 5: GitHub

GitHub (website for sharing code) requires Git. Open source, portfolios, and collaboration all happen there.


Installation Instructions

Choose your operating system:

Windows
# Windows Installation
## Step 1: Download
1. Open your browser
2. Go to: git-scm.com
3. Click "Download for Windows"
4. The installer will download automatically
## Step 2: Run Installer
1. Find and run the downloaded file
2. Click through the installer with these important choices:
Select Components:
- Keep defaults selected
Choosing the default editor:
- Choose "Use Visual Studio Code as Git's default editor"
Adjusting PATH: ⚠️ IMPORTANT
- Choose "Git from the command line and also from 3rd-party software"
HTTPS transport backend:
- Choose "Use the OpenSSL library"
Line ending conversions:
- Choose "Checkout Windows-style, commit Unix-style line endings"
Terminal emulator:
- Choose "Use Windows' default console window"
Other options:
- Keep defaults for remaining screens
3. Click Install
4. Click Finish
## Step 3: Restart VS Code
Close and reopen VS Code for changes to take effect.

Verification

Check Git Version:

Open VS Code Terminal (Ctrl/Cmd + `) and run:

Bash
git --version

Expected output:

git version 2.43.0

Version number may vary — any response means success!


Initial Configuration

Git needs to know who you are (for tracking who made changes).

Configure Your Name:

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

Replace "Your Name" with your actual name.

Example:

Bash
git config --global user.name "Alex Johnson"

Configure Your Email:

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

Use an email you'll remember — ideally the same one you'll use for GitHub later.

Example:

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

Verify Configuration:

Bash
git config --global --list

Expected output:

user.name=Alex Johnson user.email=alex.johnson@gmail.com

Optional: Set Default Editor

Tell Git to use VS Code for any text editing:

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

Configuration Checklist

Git Installation Verification

0/4

Troubleshooting


What You Can Do Now

With Git installed, you can:

1. Initialize a repository:

Bash
git init

2. Track changes:

Bash
git add .
git commit -m "Description of changes"

3. See history:

Bash
git log

4. Connect to GitHub (coming in Module 3!)

We'll learn these commands in detail later. For now, just know Git is ready!


Git Concepts Preview

Here's what you'll learn to use:

TermWhat It Means
Repository (Repo)A project tracked by Git
CommitA saved checkpoint
BranchA parallel version for experiments
PushUpload changes to GitHub
PullDownload changes from GitHub
CloneCopy a repo to your computer

Don't worry about memorizing these now — you'll learn by doing!


Lesson Summary

What You Accomplished:

  • ✅ Understand what Git is (version control)
  • ✅ Installed Git on your computer
  • ✅ Configured name and email
  • ✅ Verified installation

Why This Matters

Git is non-negotiable in professional development. Every serious project uses it, and GitHub requires it.

The Big Picture:

Text
VS Code → Where you write code
Node.js → Runs your JavaScript
Git → Tracks your changes
GitHub → Shares and backs up your code (coming in Module 3)

Knowledge Check

📝 Quiz

1/2

What is Git?


Next Up

Let's verify your entire setup is working correctly with a complete environment check!