Lösung zu Schritt 1 - Branch erstellen
Erstelle einen Branch feature-a
, bearbeite die Datei foo
und erstelle ein Commit. Wechsle dann zurück auf den main
und bearbeite dort bar
. Zeige den Commit-Graphen.
repo $ git switch -c feature-a HEAD
Switched to a new branch 'feature-a'
repo $ # Edit file foo at line 7 on branch feature-a by bjoern.
repo $ git commit -am "`foo`: Edit file foo at line 7 on branch feature-a by bjoern. "
[feature-a 300f5e9] : Edit file foo at line 7 on branch feature-a by bjoern.
1 file changed, 1 insertion(+), 1 deletion(-)
/bin/bash: line 1: foo: command not found
repo $ git switch main
Your branch is up to date with 'origin/main'.
Switched to branch 'main'
repo $ # Edit file bar at line 3 on branch main by bjoern.
repo $ git commit -am "`bar`: Edit file bar at line 3 on branch main by bjoern. "
[main b5cd7e9] : Edit file bar at line 3 on branch main by bjoern.
1 file changed, 1 insertion(+), 1 deletion(-)
/bin/bash: line 1: bar: command not found
repo $ git log --all --oneline --graph --decorate
* 300f5e9 (feature-a) : Edit file foo at line 7 on branch feature-a by bjoern.
| * b5cd7e9 (HEAD -> main) : Edit file bar at line 3 on branch main by bjoern.
|/
* 6014eb9 (origin/main) Initial edit before cloning
* de06cfe Initial edit before cloning
Lösung zu Schritt 2 - Branch mergen
Merge feature-a
auf den main
und zeige den Commit-Graphen.
repo $ git merge feature-a
Merge made by the 'ort' strategy.
foo | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
repo $ git log --all --oneline --graph --decorate
* c00b978 (HEAD -> main) Merge branch 'feature-a'
|\
| * 300f5e9 (feature-a) : Edit file foo at line 7 on branch feature-a by bjoern.
* | b5cd7e9 : Edit file bar at line 3 on branch main by bjoern.
|/
* 6014eb9 (origin/main) Initial edit before cloning
* de06cfe Initial edit before cloning
Lösung zu Schritt 3 - ⭐ Merge analysieren
Zeige, welche Commits vom main
im Merge hinzugekommen sind. Zeige, welche Commits von feature-a
im Merge hinzugekommen sind. Zeige ebenfalls die Änderungen (Diffs) für beide Seiten.
repo $ git log HEAD^2..HEAD^1
commit b5cd7e9efbe9aa3a6383b3207e231941b7d00df7
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000
: Edit file bar at line 3 on branch main by bjoern.
repo $ git log HEAD^1..HEAD^2
commit 300f5e9c1321f67c1f42fb9df9744373b4c25202
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000
: Edit file foo at line 7 on branch feature-a by bjoern.
repo $ git diff HEAD^2...HEAD^1
diff --git a/bar b/bar
index 36fe753..ce9e24d 100644
--- a/bar
+++ b/bar
@@ -1,7 +1,7 @@
line 0 created
line 1 created
line 2 created
-line 3 created
+line 3 Edit file bar at line 3 on branch main by bjoern. / line 3 created
line 4 created
line 5 created
line 6 created
repo $ git diff HEAD^1...HEAD^2
diff --git a/foo b/foo
index 36fe753..f719df0 100644
--- a/foo
+++ b/foo
@@ -5,7 +5,7 @@ line 3 created
line 4 created
line 5 created
line 6 created
-line 7 created
+line 7 Edit file foo at line 7 on branch feature-a by bjoern. / line 7 created
line 8 created
line 9 created
line 10 created
Lösung zu Schritt 4 - ⭐ Merge analysieren
Zeige, welche Commits vom main
im Merge hinzugekommen sind. Zeige, welche Commits von feature-a
im Merge hinzugekommen sind. Zeige ebenfalls die Änderungen (Diffs) für beide Seiten.
repo $ git log HEAD^2..HEAD^1
commit b5cd7e9efbe9aa3a6383b3207e231941b7d00df7
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000
: Edit file bar at line 3 on branch main by bjoern.
repo $ git log HEAD^1..HEAD^2
commit 300f5e9c1321f67c1f42fb9df9744373b4c25202
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000
: Edit file foo at line 7 on branch feature-a by bjoern.
repo $ git diff HEAD^2...HEAD^1
diff --git a/bar b/bar
index 36fe753..ce9e24d 100644
--- a/bar
+++ b/bar
@@ -1,7 +1,7 @@
line 0 created
line 1 created
line 2 created
-line 3 created
+line 3 Edit file bar at line 3 on branch main by bjoern. / line 3 created
line 4 created
line 5 created
line 6 created
repo $ git diff HEAD^1...HEAD^2
diff --git a/foo b/foo
index 36fe753..f719df0 100644
--- a/foo
+++ b/foo
@@ -5,7 +5,7 @@ line 3 created
line 4 created
line 5 created
line 6 created
-line 7 created
+line 7 Edit file foo at line 7 on branch feature-a by bjoern. / line 7 created
line 8 created
line 9 created
line 10 created
Lösung zu Schritt 5 - Remote Branches untersuchen
repo $ git branch -r -vv
origin/main 6014eb9 Initial edit before cloning
repo $ git fetch
From ../blessed
* [new branch] feature-x -> origin/feature-x
* [new branch] feature-y -> origin/feature-y
repo $ git branch -r -vv
origin/feature-x b04a371 : Edit file datei-x at line 3 on branch feature-x by bjoern.
origin/feature-y 3181804 Created file datei-y on branch feature-y by bjoern.
origin/main 6014eb9 Initial edit before cloning
repo $ git log --oneline ..origin/feature-x
b04a371 : Edit file datei-x at line 3 on branch feature-x by bjoern.
9755d66 Created file datei-x on branch feature-x by bjoern.
repo $ git log --oneline ..origin/feature-y
3181804 Created file datei-y on branch feature-y by bjoern.