t2.9/z1.txt
baiobelfer 13f944eacc refactor: simplify Git basics instructions for students
Co-authored-by: aider (openrouter/qwen/qwen3-coder) <aider@aider.chat>
2025-09-02 10:23:36 +02:00

103 lines
1.4 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

z1
z2
Sure! Below are simplified instructions for the topic **2.2 Git Basics Recording Changes in the Repository**.
# 2.2 Recording Changes in Git
## Goal
You will learn to:
* Check the repository status
* Add files to staging area
* Commit changes
* View differences
---
## Glossary
* **Tracked** file was in the last commit
* **Untracked** new file for Git
* **Staging area** list of changes that will go into the next commit
* **Commit** saved snapshot of the project
---
## Key Commands
### 1) Check status
```bash
git status
```
### 2) Add to staging area
```bash
git add filename
```
### 3) View differences
* **Changes not in staging area**:
```bash
git diff
```
* **Changes in staging area**:
```bash
git diff --staged
```
### 4) Commit changes
```bash
git commit -m "Description of changes"
```
---
## Simple workflow
1. **Check status**: `git status`
2. **Add to staging area**: `git add <file>`
3. **Commit**: `git commit -m "Description"`
---
## Exercise (10 min)
1. **Create a repository**
```bash
git init git-lesson
cd git-lesson
```
2. **Create and commit a file**
```bash
echo "Hello Git!" > README.md
git add README.md
git commit -m "Add README"
```
3. **Modify the file**
```bash
echo "Second line" >> README.md
git status
git diff
git add README.md
git commit -m "Add second line"
```
4. **Check history**
```bash
git log --oneline
```