Solution to Step 0 - START
Solution to Step 1 - The first repo
Create your first repository with the following commands:
$ git init myrepo
$ cd myrepo
$ echo 'welt' >hallo # creates a file
$ git add hallo
$ git commit -m 'Hello World!'
$ git log
$ git init -b main myrepo
Initialized empty Git repository in /workspaces/git-workshop/build/git-uebungen-en/loesungen/intro-hallo-welt/myrepo/.git/
$ cd myrepo
myrepo $ echo 'welt' >hallo
myrepo $ git add hallo
myrepo $ git commit -m 'Hallo Welt!'
[main (root-commit) 48dd4eb] Hallo Welt!
1 file changed, 1 insertion(+)
create mode 100644 hallo
Congratulations: You see your first commit in your first Git repository!
myrepo $ git log
commit 48dd4eb91e6605e068edb66c2653303502812e3b
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000
Hallo Welt!
myrepo $ cd ..
Solution to Step 2 - ⭐ And another commit
Edit the file ‘hallo’ and create a new commit. With the -am
option, you don’t need to call git add hallo
again. Then look at the log.
$ git commit -am 'Here we go again!'
$ git log
$ cd myrepo
myrepo $ # Edit file hallo
myrepo $ git commit -am 'Es geht weiter!'
[main c3a1c04] Es geht weiter!
1 file changed, 1 insertion(+), 1 deletion(-)
myrepo $ git log
commit c3a1c04f58ca34e8e7ba0ed339dd7735d0c03ae6
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000
Es geht weiter!
commit 48dd4eb91e6605e068edb66c2653303502812e3b
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000
Hallo Welt!
myrepo $ cd ..
Solution to Step 3 - ⭐ Where is the repository
Examine the directory. Where is the Git repository located? What does it contain?
$ ll -a
$ ll .git/
$ cd myrepo
myrepo $ ll -a
total 16K
drwxr-xr-x 3 vscode vscode 4.0K .
drwxr-xr-x 3 vscode vscode 4.0K ..
drwxr-xr-x 7 vscode vscode 4.0K .git
-rw-r--r-- 1 vscode vscode 10 hallo
myrepo $ ll -a .git/
total 48K
drwxr-xr-x 7 vscode vscode 4.0K .
drwxr-xr-x 3 vscode vscode 4.0K ..
-rw-r--r-- 1 vscode vscode 16 COMMIT_EDITMSG
-rw-r--r-- 1 vscode vscode 21 HEAD
-rw-r--r-- 1 vscode vscode 92 config
-rw-r--r-- 1 vscode vscode 73 description
drwxr-xr-x 2 vscode vscode 4.0K hooks
-rw-r--r-- 1 vscode vscode 137 index
drwxr-xr-x 2 vscode vscode 4.0K info
drwxr-xr-x 3 vscode vscode 4.0K logs
drwxr-xr-x 10 vscode vscode 4.0K objects
drwxr-xr-x 4 vscode vscode 4.0K refs
myrepo $ cd ..