t2.9/z1.txt

103 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

2025-09-02 07:07:15 +00:00
z1
2025-09-02 07:32:18 +00:00
z2
Sure! Below are simplified instructions for the topic **2.2 Git Basics Recording Changes in the Repository**.
2025-09-02 07:03:49 +00:00
# 2.2 Recording Changes in Git
2025-09-02 07:03:49 +00:00
## Goal
2025-09-02 07:03:49 +00:00
You will learn to:
2025-09-02 07:03:49 +00:00
* Check the repository status
* Add files to staging area
* Commit changes
* View differences
2025-09-02 07:03:49 +00:00
---
## Glossary
2025-09-02 07:03:49 +00:00
* **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
2025-09-02 07:03:49 +00:00
---
## Key Commands
2025-09-02 07:03:49 +00:00
### 1) Check status
2025-09-02 07:03:49 +00:00
```bash
git status
```
### 2) Add to staging area
2025-09-02 07:03:49 +00:00
```bash
git add filename
2025-09-02 07:03:49 +00:00
```
### 3) View differences
2025-09-02 07:03:49 +00:00
* **Changes not in staging area**:
2025-09-02 07:03:49 +00:00
```bash
git diff
```
* **Changes in staging area**:
2025-09-02 07:03:49 +00:00
```bash
git diff --staged
2025-09-02 07:03:49 +00:00
```
### 4) Commit changes
2025-09-02 07:03:49 +00:00
```bash
git commit -m "Description of changes"
2025-09-02 07:03:49 +00:00
```
---
## Simple workflow
2025-09-02 07:03:49 +00:00
1. **Check status**: `git status`
2. **Add to staging area**: `git add <file>`
3. **Commit**: `git commit -m "Description"`
2025-09-02 07:03:49 +00:00
---
## Exercise (10 min)
2025-09-02 07:03:49 +00:00
1. **Create a repository**
2025-09-02 07:03:49 +00:00
```bash
git init git-lesson
cd git-lesson
```
2. **Create and commit a file**
2025-09-02 07:03:49 +00:00
```bash
echo "Hello Git!" > README.md
2025-09-02 07:03:49 +00:00
git add README.md
git commit -m "Add README"
2025-09-02 07:03:49 +00:00
```
3. **Modify the file**
2025-09-02 07:03:49 +00:00
```bash
echo "Second line" >> README.md
git status
git diff
git add README.md
git commit -m "Add second line"
2025-09-02 07:03:49 +00:00
```
4. **Check history**
2025-09-02 07:03:49 +00:00
```bash
git log --oneline
2025-09-02 07:03:49 +00:00
```