79 lines
2.5 KiB
Markdown
79 lines
2.5 KiB
Markdown
# Module 01: Git Basics
|
|
|
|
## Learning Objectives
|
|
|
|
- Understand what a git repository is
|
|
- Learn the basic git workflow: modify → stage → commit
|
|
- Use `git status` to check repository state
|
|
- Use `git add` to stage changes
|
|
- Use `git commit` to save changes
|
|
|
|
## Challenge
|
|
|
|
In this challenge, you'll learn the fundamental git workflow.
|
|
|
|
### Setup
|
|
|
|
Run the setup script to prepare the challenge:
|
|
|
|
```powershell
|
|
.\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:
|
|
|
|
1. Navigate into the `challenge` directory: `cd challenge`
|
|
2. **Initialize a new git repository**: `git init` (this is your first step!)
|
|
3. Check the status of your repository: `git status`
|
|
4. Stage the files you want to commit: `git add welcome.txt` (or `git add .` to stage all files)
|
|
5. Create a commit: `git commit -m "Your commit message"`
|
|
6. 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
|
|
|
|
```bash
|
|
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:
|
|
|
|
```powershell
|
|
.\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:
|
|
|
|
```powershell
|
|
.\reset.ps1
|
|
```
|
|
|
|
This will remove your challenge directory and set up a new one.
|