Solution to Step 0 - START

Solution to Step 1 - Integrating modules as subtrees

Integrate the modules frontend.git and backend.git using subtree add. Then examine the resulting directory structure.

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

Solution to Step 2 - Adopting changes from a module

Go to the backend repo, change the service.java file, commit and push. Look at the resulting commit (show --stat) Go to the application repo and fetch the changes using subtree pull. Look at the transferred commit.

$ 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 ..


Solution to Step 3 - Transferring changes to a module

Go to application, change frontend/main.ts and commit. Transfer the change to frontend.git using subtree push. Look at the transferred commit in frontend.git.

$ 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 ..


Solution to Step 4 - Cloning the parent repo

Clone application to myapplication. Examine the HEAD directory structure, and the commit graph.

$ git clone application myapplication

Cloning into 'myapplication'...
done.

$ cd myapplication


You can see that the embeddings appear as normal files and directories in the HEAD tree

myapplication $ git ls-tree -r HEAD .

100644 blob 36fe7538890f39b90ff7dee1d1f97ba3e3a9350c README
100644 blob 6429de2def6cf09854047acb14ee781e65462881 backend/service.java
100644 blob ab09e17b67ee7ec9f019c779211387d58e69f214 frontend/main.ts

In the commit graph you can see, where the data comes from.

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 ..


To the exercise

To the overview