# Module 02: Viewing History ## Learning Objectives In this module, you will: - Understand commit history and how to navigate it - Use `git log` to view commit history with various formats - Use `git show` to view specific commit details - Use `git diff` to compare changes between commits - Understand commit hashes and references ## Challenge ### Setup Run the setup script to create your challenge environment: ```powershell .\setup.ps1 ``` This will create a `challenge/` directory with a Git repository that already has some commit history. ### Your Task You'll explore an existing Git repository that contains multiple commits. Your goal is to use Git commands to discover information about the repository's history and answer the following questions: 1. **How many commits are in the repository?** 2. **What was the commit message for the third commit?** (counting from the first/oldest commit) 3. **Which file was modified in the "Fix authentication bug" commit?** 4. **What changes were made to app.py between the first and last commits?** (briefly describe) Create a file called `answers.txt` in the challenge directory with your answers. You can format your answers however you like, as long as the information is there. **Suggested Approach:** 1. Navigate to the challenge directory: `cd challenge` 2. View the commit history: `git log` 3. Try different log formats: `git log --oneline`, `git log --stat` 4. View specific commits: `git show ` 5. Compare commits: `git diff ` 6. Create `answers.txt` with your findings > **Important Notes:** > - You can use any Git commands you like to explore the repository > - The format of your answers is flexible - just make sure the information is clear > - Try different `git log` options to see which format you prefer > - Commit hashes can be referenced by their full hash or just the first 7 characters ## Key Concepts - **Commit Hash**: A unique identifier (SHA-1 hash) for each commit. You can use the full hash or just the first few characters. - **Commit Message**: A description of what changed in that commit, written by the author. - **Commit History**: The chronological record of all changes made to a repository. - **HEAD**: A pointer to the current commit you're working from. ## Useful Commands ```bash git log # View commit history git log --oneline # Compact one-line format git log --stat # Show files changed in each commit git log --graph # Show branch graph (more useful with branches) git show # View specific commit details git show : # View a file from a specific commit git diff # Compare two commits git diff # Compare commit with current working directory ``` ## Verification Once you've created your `answers.txt` file, verify your solution: ```powershell .\verify.ps1 ``` The verification script will check that your answers contain the expected information. ## Need to Start Over? If you want to reset the challenge and start fresh: ```powershell .\reset.ps1 ``` This will remove the challenge directory and run the setup script again, giving you a clean slate.