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 7472c9a] Erste ?nderung
1 file changed, 1 insertion(+), 1 deletion(-)
repo $ git show
commit 7472c9afd84a9c8b77a5581c15b41220b0c50209
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 478ab67] Zweite ?nderung
1 file changed, 1 insertion(+), 1 deletion(-)
With the -a
option, you can save the add
call:
repo $ git log --oneline
478ab67 Zweite ?nderung
7472c9a 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 767f657] 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 b4d22e4] 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 601dbf4] 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 dee82fa] 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
dee82fa 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 e768993] B?se umbenennen
2 files changed, 1 insertion(+), 12 deletions(-)
delete mode 100644 datei1
create mode 100644 datei2
repo $ git log --follow --oneline -- datei2
e768993 B?se umbenennen