Solution to Step 0 - START

Solution to Step 1 - Commit - with Staging

Edit the file hallo-welt, add it to the index with git add (staging) and create a commit with these changes.

repo $ # Edit file hallo-welt


repo $ git add hallo-welt


repo $ git commit -m 'Erste Änderung'

[main 8e6f221] Erste Änderung
1 file changed, 1 insertion(+), 1 deletion(-)

repo $ git show

commit 8e6f221a4064202a3e00c80e811334dc72d1bd39
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000

Erste Änderung

diff --git a/hallo-welt b/hallo-welt
index a92550c..dfb4ae8 100644
--- a/hallo-welt
+++ b/hallo-welt
@@ -1 +1 @@
-Hallo Welt
\ No newline at end of file
+Hallo Welt!
\ No newline at end of file

Solution to Step 2 - Commit - automatic staging

Edit the file hallo-welt again and create another commit, but this time with -a.

repo $ # Edit file hallo-welt


repo $ git commit -am 'Zweite Änderung'

[main 6aa80c5] Zweite Änderung
1 file changed, 1 insertion(+), 1 deletion(-)

With the -a option, you can save the add call:

repo $ git log --oneline

6aa80c5 Zweite Änderung
8e6f221 Erste Änderung
8d91794 Created file datei1 on branch main by bjoern.
331ed0e Created file hello-world on branch main by bjoern.
f55db71 Created file hallo-welt on branch main by bjoern.

Solution to Step 3 - Commit - new file

Create new-world and confirm it with a commit.

repo $ # created file 'new-world'


repo $ # Edit file new-world


repo $ git add new-world


repo $ git commit -m 'Neue Datei'

[main 35612a2] Neue Datei
1 file changed, 1 insertion(+)
create mode 100644 new-world

Solution to Step 4 - Commit - delete file

Delete hallo-welt and confirm this with a commit.

repo $ rm hallo-welt


repo $ git commit -am 'Datei löschen'

[main 7f7a567] Datei löschen
1 file changed, 1 deletion(-)
delete mode 100644 hallo-welt

Solution to Step 5 - ⭐ Add - recursively add files

Create a file superneu and a directory sub with a file auchneu, add both with one add call and then create a commit.

repo $ # created file 'superneu'


repo $ mkdir sub


sub $ cd sub


sub $ # created file 'auchneu'


sub $ cd ..


. stands for: current directory.” All files in it and below it will be added.

repo $ git add .


repo $ git commit -am 'Neue Dateien'

[main 9ea75ca] Neue Dateien
2 files changed, 24 insertions(+)
create mode 100644 sub/auchneu
create mode 100644 superneu

Solution to Step 6 - ⭐ Commit - move/rename file

Rename the file hello-world to renamed-world and confirm this with a commit.

repo $ mv hello-world renamed-world


repo $ git add renamed-world


repo $ git commit -am 'Umbenennen'

[main a8c7bd8] Umbenennen
1 file changed, 0 insertions(+), 0 deletions(-)
rename hello-world => renamed-world (100%)

Note: If we had used git mv instead of mv, the separate git add would not have been necessary.

repo $ git log --follow --oneline -- renamed-world

a8c7bd8 Umbenennen
331ed0e Created file hello-world on branch main by bjoern.

Solution to Step 7 - ⭐ Rename detection

Rename the file datei1 to datei2 with git mv. Make sure that the Rename Detection does not recognize this.

repo $ git mv datei1 datei2


repo $ # Edit file datei2


repo $ git commit -am 'Böse umbenennen'

[main 2a7ad75] Böse umbenennen
2 files changed, 1 insertion(+), 12 deletions(-)
delete mode 100644 datei1
create mode 100644 datei2

repo $ git log --follow --oneline -- datei2

2a7ad75 Böse umbenennen

To the exercise

To the overview