Lösung zu Schritt 1 - Module als Subtree einbinden
Binde die Module frontend.git
und backend.git
per subtree add
ein. Untersuche dann die entstandene Verzeichnisstruktur.
application $ git subtree add --prefix=frontend ../frontend.git main
git fetch ../frontend.git main
From ../frontend
* branch main -> FETCH_HEAD
Added dir 'frontend'
application $ git subtree add --prefix=backend ../backend.git main
git fetch ../backend.git main
From ../backend
* branch main -> FETCH_HEAD
Added dir 'backend'
application $ git ls-tree -r HEAD
100644 blob 36fe7538890f39b90ff7dee1d1f97ba3e3a9350c README
100644 blob 36fe7538890f39b90ff7dee1d1f97ba3e3a9350c backend/service.java
100644 blob 36fe7538890f39b90ff7dee1d1f97ba3e3a9350c frontend/main.ts
Lösung zu Schritt 2 - Änderung aus einem Modul übernehmen
Gehe in das Repo backend
ändere die Datei service.java
, committe und pushe. Sie Dir das entstandene Commit an (show --stat
) Gehe in das Repo application
und hole die Änderungen per subtree pull
ab. Sieh Dir das übertragene Commit an.
$ cd backend
backend $ # Edit file service.java at line 7 on branch main by bjoern.
backend $ git commit -am "`service.java`: Edit file service.java at line 7 on branch main by bjoern. "
[main 45a3d13] : Edit file service.java at line 7 on branch main by bjoern.
1 file changed, 1 insertion(+), 1 deletion(-)
/bin/bash: line 1: service.java: command not found
backend $ git show --stat
commit 45a3d1300877eb63e155cc2d9e48c0e9c6dd9d40
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000
: Edit file service.java at line 7 on branch main by bjoern.
service.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
backend $ git push
To ../backend.git
005d8aa..45a3d13 main -> main
backend $ cd ..
$ cd application
application $ git subtree pull --prefix=backend ../backend.git main
Merge made by the 'ort' strategy.
backend/service.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From ../backend
* branch main -> FETCH_HEAD
application $ git show --stat
commit 5212dee0f6c96681e7d5f9bb60780d4c1b474223
Merge: 8453b78 45a3d13
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000
Merge commit '45a3d1300877eb63e155cc2d9e48c0e9c6dd9d40'
backend/service.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
application $ cd ..
Lösung zu Schritt 3 - Änderung in ein Modul übertragen
Gehe in application
ändere frontend/main.ts
und committe. Übertrage die Änderung per subtree push
nach frontend.git
. Sieh Dir das übertragene Commit in frontend.git
an.
$ cd application
frontend $ # Edit file frontend/main.ts at line 3 on branch main by bjoern.
application $ git commit -am "`frontend/main.ts`: Edit file frontend/main.ts at line 3 on branch main by bjoern. "
[main ec22756] : Edit file frontend/main.ts at line 3 on branch main by bjoern.
1 file changed, 1 insertion(+), 1 deletion(-)
/bin/bash: line 1: frontend/main.ts: Permission denied
application $ git subtree push --prefix=frontend ../frontend.git main
git push using: ../frontend.git main
1/8 (0) [0]
2/8 (0) [0]
3/8 (0) [0]
3/8 (1) [1]
3/8 (1) [2]
4/8 (1) [2]
5/8 (2) [2]
5/8 (3) [3]
6/8 (3) [3]
7/8 (4) [3]
7/8 (5) [4]
8/8 (5) [4]
To ../frontend.git
03baf80..9353bac 9353bac2fbbe00cace23ed6a85fae2c02d7ebe58 -> main
application $ cd ..
$ cd frontend.git
frontend.git $ git show --stat
commit 9353bac2fbbe00cace23ed6a85fae2c02d7ebe58
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000
: Edit file frontend/main.ts at line 3 on branch main by bjoern.
main.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
frontend.git $ cd ..
Lösung zu Schritt 4 - Übergeordnetes Repo klonen
Klone application
zu myapplication
. Untersuche die HEAD
Verzeichnisstruktur, und den Commit-graphen.
$ git clone application myapplication
Cloning into 'myapplication'...
done.
$ cd myapplication
Man sieht, dass die Einbettungen als normale Dateien und Verzeichnisse im HEAD
-Tree erscheinen
myapplication $ git ls-tree -r HEAD .
100644 blob 36fe7538890f39b90ff7dee1d1f97ba3e3a9350c README
100644 blob 6429de2def6cf09854047acb14ee781e65462881 backend/service.java
100644 blob ab09e17b67ee7ec9f019c779211387d58e69f214 frontend/main.ts
Im Commit-Graphen sieht man, woher die Daten kommen.
myapplication $ git log --graph --oneline --stat
* ec22756 : Edit file frontend/main.ts at line 3 on branch main by bjoern.
| frontend/main.ts | 2 +-
| 1 file changed, 1 insertion(+), 1 deletion(-)
* 5212dee Merge commit '45a3d1300877eb63e155cc2d9e48c0e9c6dd9d40'
|\
| * 45a3d13 : Edit file service.java at line 7 on branch main by bjoern.
| | service.java | 2 +-
| | 1 file changed, 1 insertion(+), 1 deletion(-)
* | 8453b78 Add 'backend/' from commit '005d8aaf310fef036b86d5f6cae09f9ac8477669'
|\|
| * 005d8aa Created file service.java on branch main by bjoern.
| service.java | 12 ++++++++++++
| 1 file changed, 12 insertions(+)
* 3c353b4 Add 'frontend/' from commit '03baf805ce0819e534d14835f60a2267a465bc98'
|\
| * 03baf80 Created file main.ts on branch main by bjoern.
| main.ts | 12 ++++++++++++
| 1 file changed, 12 insertions(+)
* 74f11b3 Created file README on branch main by bjoern.
README | 12 ++++++++++++
1 file changed, 12 insertions(+)
myapplication $ cd ..