Module Overview
What You'll Learn
- Install and configure Git
- Create your first repository
- Add and commit files
- Understand the staging area
Time Estimate
30-45 minutes
Prerequisites
Module 0: Foundations
Installation & Configuration
Installing Git
macOS
brew install git
Linux (Ubuntu/Debian)
sudo apt-get install git
Initial Configuration
Set up your identity for Git commits:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git config --list
🎯 Try It Yourself
Open your terminal and run these commands to verify your Git installation:
Creating Your First Repository
Initialize a Repository
Create a new Git repository in an existing directory:
mkdir my-first-project
cd my-first-project
git init
Understanding the .git Directory
When you run git init
, Git creates a hidden .git
directory that contains:
- HEAD - Points to the current branch
- objects/ - Stores all your data
- refs/ - Stores pointers to commit objects
- config - Repository-specific configuration
🔧 Hands-On Exercise
Create your first repository and explore its structure:
Understanding the Staging Area
The Three States
Working Directory
Files you're actively editing
Staging Area
Files ready to be committed
Repository
Committed snapshots
Basic Commands
git status
Check the status of your working directory and staging area
git status
git add
Stage files for commit
git add filename.txt
git add .
git commit
Create a commit with staged changes
git commit -m "Initial commit"
git commit -am "Add and commit all tracked files"
💡 Practice Exercise
Create a file and practice the basic workflow:
Module Quiz
Test your understanding of Git basics: