This commit is contained in:
171
07_git/docs/git-project.md
Normal file
171
07_git/docs/git-project.md
Normal file
@@ -0,0 +1,171 @@
|
||||
# Git Projektanweisung
|
||||
|
||||
1. **Projektordner vorbereiten & Git initialisieren:**
|
||||
Erstelle das Verzeichnis, wechsle hinein, initialisiere das Repository direkt mit dem Standard-Branch `main` und stelle sicher, dass kein alter `master`-Branch existiert.
|
||||
|
||||
```bash
|
||||
mkdir project-git
|
||||
cd project-git
|
||||
git init -b main
|
||||
|
||||
# Prüfung/Bereinigung falls 'master' noch existieren sollte:
|
||||
git branch -d master 2>/dev/null || true
|
||||
|
||||
```
|
||||
|
||||
|
||||
2. **README.md erstellen & committen:**
|
||||
Erstelle die Datei mit der geforderten Überschrift und führe den initialen Commit auf `main` durch.
|
||||
|
||||
```bash
|
||||
echo "# Implementierung eines Workflows" > README.md
|
||||
git add README.md
|
||||
git commit -m "docs: add initial README.md"
|
||||
|
||||
```
|
||||
|
||||
|
||||
3. **Feature-Branches anlegen:**
|
||||
Erstelle die beiden Branches `feature-1` und `feature-2` ausgehend vom aktuellen Stand auf `main`.
|
||||
|
||||
```bash
|
||||
git branch feature-1
|
||||
git branch feature-2
|
||||
|
||||
```
|
||||
|
||||
|
||||
4. **Arbeiten auf feature-1 (2 Commits):**
|
||||
Wechsle zu `feature-1`, erstelle `feature1.txt` und führe zwei getrennte Commits durch.
|
||||
|
||||
```bash
|
||||
git checkout feature-1
|
||||
|
||||
# Commit 1
|
||||
echo "Feature 1: Basis-Funktionalitaet" > feature1.txt
|
||||
git add feature1.txt
|
||||
git commit -m "feat: add feature1.txt with base logic"
|
||||
|
||||
# Commit 2
|
||||
echo "Feature 1: Erweiterung" >> feature1.txt
|
||||
git add feature1.txt
|
||||
git commit -m "feat: extend feature1.txt functionality"
|
||||
|
||||
```
|
||||
|
||||
|
||||
5. **Arbeiten auf feature-2 (2 Commits):**
|
||||
Wechsle zu `feature-2`, erstelle `feature2.txt` und führe ebenfalls zwei Commits durch.
|
||||
|
||||
```bash
|
||||
git checkout feature-2
|
||||
|
||||
# Commit 1
|
||||
echo "Feature 2: Erste Implementierung" > feature2.txt
|
||||
git add feature2.txt
|
||||
git commit -m "feat: add feature2.txt with base logic"
|
||||
|
||||
# Commit 2
|
||||
echo "Feature 2: Erweiterte Logik" >> feature2.txt
|
||||
git add feature2.txt
|
||||
git commit -m "feat: extend feature2.txt functionality"
|
||||
|
||||
```
|
||||
|
||||
|
||||
6. **feature-1 mergen & Tag v1.1.0 setzen:**
|
||||
Wechsle zurück auf `main`, führe den Merge für `feature-1` durch und tagge den ersten stabilen Zustand.
|
||||
|
||||
```bash
|
||||
git checkout main
|
||||
git merge feature-1 --no-edit
|
||||
git tag v1.1.0
|
||||
|
||||
```
|
||||
|
||||
|
||||
7. **feature-2 mergen & Tag v1.2.0 setzen:**
|
||||
Merge `feature-2` in den `main`-Branch und setze den nächsten Versions-Tag.
|
||||
|
||||
```bash
|
||||
git merge feature-2 --no-edit
|
||||
git tag v1.2.0
|
||||
|
||||
```
|
||||
|
||||
|
||||
8. **Gestagte und ungestagte Änderungen in feature-1 vornehmen:**
|
||||
Wechsle zurück zu `feature-1`. Erzeuge eine gestagte sowie eine ungestagte Änderung und speichere den Status-Dump.
|
||||
|
||||
```bash
|
||||
git checkout feature-1
|
||||
|
||||
# Gestagte Aenderung:
|
||||
echo "Aenderung 1 (gestaged)" >> feature1.txt
|
||||
git add feature1.txt
|
||||
|
||||
# Ungestagte Aenderung:
|
||||
echo "Aenderung 2 (ungestaged)" >> feature1.txt
|
||||
|
||||
# Status in Datei schreiben:
|
||||
git status > status.dump
|
||||
|
||||
```
|
||||
|
||||
|
||||
9. **Änderungen stashen:**
|
||||
Sichere alle Änderungen inklusive ungetrackter Dateien (`status.dump`) im Stash mit der geforderten Beschreibung.
|
||||
|
||||
```bash
|
||||
git stash push -u -m "Stash 1: Hotfix needed"
|
||||
|
||||
```
|
||||
|
||||
|
||||
10. **Hotfix-Branch erstellen, fixen & mergen:**
|
||||
Zweige vom Tag `v1.2.0` ab, erstelle `stash.dump`, committe diesen Fix und merge alles in `main`.
|
||||
|
||||
```bash
|
||||
# Hotfix-Branch von v1.2.0 erstellen:
|
||||
git checkout -b hotfix v1.2.0
|
||||
|
||||
# Stash-Liste exportieren und committen:
|
||||
git stash list > stash.dump
|
||||
git add stash.dump
|
||||
git commit -m "fix: resolve critical issue via stash inspection"
|
||||
|
||||
# In main mergen:
|
||||
git checkout main
|
||||
git merge hotfix --no-edit
|
||||
|
||||
```
|
||||
|
||||
|
||||
11. **feature-1 fortsetzen, abschließen & v1.2.1 taggen:**
|
||||
Kehre zu `feature-1` zurück, hole die Änderungen aus dem Stash, committe sie, merge den Branch in `main` und setze das finale Tag.
|
||||
|
||||
```bash
|
||||
git checkout feature-1
|
||||
git stash pop
|
||||
|
||||
# Alle wiederhergestellten Aenderungen committen:
|
||||
git add .
|
||||
git commit -m "feat: complete pending work on feature1"
|
||||
|
||||
# In main mergen und taggen:
|
||||
git checkout main
|
||||
git merge feature-1 --no-edit
|
||||
git tag v1.2.1
|
||||
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
Zur finalen Überprüfung der Tags und des Graphen:
|
||||
|
||||
```bash
|
||||
git tag
|
||||
git log --oneline --graph --all
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user