Module 01: Git Basics
Learning Objectives
- Understand what a git repository is
- Learn the basic git workflow: modify → stage → commit
- Use
git statusto check repository state - Use
git addto stage changes - Use
git committo save changes
Challenge
In this challenge, you'll learn the fundamental git workflow.
Setup
Run the setup script to prepare the challenge:
.\setup.ps1
This will create a directory called challenge with some files that need to be committed.
Your Task
Your goal is to commit both welcome.txt and instructions.txt to a git repository. Here's a suggested approach:
- Navigate into the
challengedirectory:cd challenge - Initialize a new git repository:
git init(this is your first step!) - Check the status of your repository:
git status - Stage the files you want to commit:
git add welcome.txt(orgit add .to stage all files) - Create a commit:
git commit -m "Your commit message" - Verify both files are committed:
git ls-tree -r HEAD --name-only
Important Notes:
- The challenge directory is NOT a git repository until you run
git init. This is intentional - you're learning to start from scratch! - You can commit both files together in one commit, or separately in multiple commits - it's up to you!
- The verification script checks that both files are committed, not the specific commit messages or order
Key Concepts
- Repository: A directory tracked by git, containing your project files and their history
- Working Directory: The files you see and edit
- Staging Area (Index): A preparation area for your next commit
- Commit: A snapshot of your staged changes
Useful Commands
git init # Initialize a new git repository
git status # Show the working tree status
git add <file> # Stage a specific file for commit
git add . # Stage all files in current directory
git commit -m "<message>" # Create a commit with a message
git ls-tree -r HEAD --name-only # List all files in the latest commit
git log # View commit history
Verification
Once you think you've completed the challenge, run:
.\verify.ps1
This will check if you've successfully completed all the steps.
Need to Start Over?
If you want to reset the challenge and start fresh, run:
.\reset.ps1
This will remove your challenge directory and set up a new one.