chore: initial training material setup

This commit is contained in:
2026-05-12 20:34:39 +02:00
commit 2314a14916
20 changed files with 1865 additions and 0 deletions
+125
View File
@@ -0,0 +1,125 @@
# ✅ Lösung Aufgabe 03: Branches
> Schau dir diese Lösung erst an, nachdem du die Aufgabe selbst versucht hast!
---
## Schritt-für-Schritt-Lösung
### 1. Ausgangssituation herstellen
```bash
mkdir branch-uebung
cd branch-uebung
git init
echo "# Branch-Übung" > README.md
git add README.md
git commit -m "chore: Projekt angelegt"
```
### 2. Feature-Branch anlegen
```bash
git switch -c feature/begruessung
```
```text
Switched to a new branch 'feature/begruessung'
```
### 3. Datei erstellen und committen
```bash
echo "Hallo, Welt!" > hallo.txt
echo "Willkommen in meinem ersten Git-Projekt." >> hallo.txt
git add hallo.txt
git commit -m "feat: Begrüßungsdatei hinzugefügt"
```
```text
[feature/begruessung c3d4e56] feat: Begrüßungsdatei hinzugefügt
1 file changed, 2 insertions(+)
create mode 100644 hallo.txt
```
### 4. Zurück zu main
```bash
git switch main
```
```text
Switched to branch 'main'
```
Prüfe, ob `hallo.txt` da ist:
```bash
ls
```
```text
README.md
```
`hallo.txt` fehlt korrekt! Auf `main` existiert sie noch nicht.
### 5. Commit-Übersicht beider Branches
```bash
git log --all --oneline --graph
```
```text
* c3d4e56 (feature/begruessung) feat: Begrüßungsdatei hinzugefügt
* a1b2c3d (HEAD -> main) chore: Projekt angelegt
```
### 6. Merge
```bash
git merge feature/begruessung
```
```text
Updating a1b2c3d..c3d4e56
Fast-forward
hallo.txt | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 hallo.txt
```
`hallo.txt` ist jetzt auf `main` vorhanden.
### 7. Branch aufräumen
```bash
git branch -d feature/begruessung
```
```text
Deleted branch feature/begruessung (was c3d4e56).
```
### Abschlusszustand
```bash
git log --oneline
```
```text
c3d4e56 (HEAD -> main) feat: Begrüßungsdatei hinzugefügt
a1b2c3d chore: Projekt angelegt
```
```bash
git branch
```
```text
* main
```
---
*Zurück zur [Aufgabe](../03-branches/aufgabe.md)*