Solution to Step 0 - START
Solution to Step 1 - Staging
In the file demo, replace Fit with Git. Then add it to the stage area. Then replace doof with toll. Show the status and diffs for the workspace and stage.
Replace Fit with Git.
repo $ # Edit file demo
repo $ git add demo
Replace doof with toll.
repo $ # Edit file demo
repo $ git status
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: demo
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: demo
The file demo is listed in both Changes to be committed: and Changes not staged for commit.
repo $ git diff
diff --git a/demo b/demo
index 94cc8b3..70971ae 100644
--- a/demo
+++ b/demo
@@ -1,3 +1,3 @@
Git
ist
-doof.
+toll.
You can see that the stage area has a different diff than the workspace.
repo $ git diff --staged
diff --git a/demo b/demo
index af77d0b..94cc8b3 100644
--- a/demo
+++ b/demo
@@ -1,3 +1,3 @@
-Fit
+Git
ist
doof.
Solution to Step 2 - Restore - Staging zurücknehmen
The last change should not be included in the next commit yet, so undo it.
repo $ git restore --staged demo
repo $ git status
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: demo
no changes added to commit (use "git add" and/or "git commit -a")
repo $ git diff
diff --git a/demo b/demo
index af77d0b..70971ae 100644
--- a/demo
+++ b/demo
@@ -1,3 +1,3 @@
-Fit
+Git
ist
-doof.
+toll.
After undoing, the stage area is empty again.
repo $ git diff --staged
Solution to Step 3 - Restore - Änderung ganz zurücknehmen
The changes to demo should be completely undone. Show the status and diffs afterwards.
repo $ git status
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: demo
no changes added to commit (use "git add" and/or "git commit -a")
repo $ git restore demo
repo $ git status
On branch main
nothing to commit, working tree clean
repo $ git diff
repo $ git diff --staged
Now the changes are completely gone.
Solution to Step 4 - ⭐ Restore - Älteren Inhalt einer Datei zurückholen
The file beispiel was edited three times. Restore the middle state and create a commit.
repo $ git log --oneline beispiel
c67dc27 später
4222f43 dazwischen
dfe79fa dazwischen
repo $ git restore -s HEAD~9 beispiel
repo $ git diff
diff --git a/beispiel b/beispiel
index c571ad6..ab1b57f 100644
--- a/beispiel
+++ b/beispiel
@@ -1 +1 @@
-Und so endete es.
\ No newline at end of file
+Dann kam das mit dem Mittelteil.
\ No newline at end of file
repo $ git commit -am "Mittlerer Stand wiederhergestellt."
[main 2045b52] Mittlerer Stand wiederhergestellt.
1 file changed, 1 insertion(+), 1 deletion(-)
Solution to Step 5 - ⭐ Restore - Zurückholen älterer Verzeichnisversionen
A game was played in the ufer folder. Recreate the game states by applying restore to the ufer directory.
Tip: ll ufer/* shows the directories of the game.
Tip: When using restore, untracked files are not removed. You can remove them with the stash command.
repo $ git log --oneline -- ufer/
b1ef622 Zug 7
f4bd978 Zug 6
d9717fe Zug 5
c3aaf58 Zug 4
742e18c Zug 3
ea7b14c Zug 2
751d90f Zug 1
cdc2f48 Starte spiel
Move 1
repo $ git stash -u
No local changes to save
repo $ git restore -s HEAD~7 ufer
repo $ ll ufer/*
ufer/ost:
total 8.0K
-rw-r--r-- 1 vscode vscode 181 BAUER
-rw-r--r-- 1 vscode vscode 181 ZIEGE
ufer/west:
total 8.0K
-rw-r--r-- 1 vscode vscode 181 KOHL
-rw-r--r-- 1 vscode vscode 181 WOLF
Move 2
repo $ git stash -u
Saved working directory and index state WIP on main: 2045b52 Mittlerer Stand wiederhergestellt.
repo $ git restore -s HEAD~6 ufer
repo $ ll ufer/*
ufer/ost:
total 4.0K
-rw-r--r-- 1 vscode vscode 181 ZIEGE
ufer/west:
total 12K
-rw-r--r-- 1 vscode vscode 181 BAUER
-rw-r--r-- 1 vscode vscode 181 KOHL
-rw-r--r-- 1 vscode vscode 181 WOLF
Move 3
repo $ git stash -u
Saved working directory and index state WIP on main: 2045b52 Mittlerer Stand wiederhergestellt.
repo $ git restore -s HEAD~5 ufer
repo $ ll ufer/*
ufer/ost:
total 12K
-rw-r--r-- 1 vscode vscode 181 BAUER
-rw-r--r-- 1 vscode vscode 181 WOLF
-rw-r--r-- 1 vscode vscode 181 ZIEGE
ufer/west:
total 4.0K
-rw-r--r-- 1 vscode vscode 181 KOHL
Move 4
repo $ git stash -u
Saved working directory and index state WIP on main: 2045b52 Mittlerer Stand wiederhergestellt.
repo $ git restore -s HEAD~4 ufer
repo $ ll ufer/*
ufer/ost:
total 4.0K
-rw-r--r-- 1 vscode vscode 181 WOLF
ufer/west:
total 12K
-rw-r--r-- 1 vscode vscode 181 BAUER
-rw-r--r-- 1 vscode vscode 181 KOHL
-rw-r--r-- 1 vscode vscode 181 ZIEGE
Move 5
repo $ git stash -u
Saved working directory and index state WIP on main: 2045b52 Mittlerer Stand wiederhergestellt.
repo $ git restore -s HEAD~3 ufer
repo $ ll ufer/*
ufer/ost:
total 12K
-rw-r--r-- 1 vscode vscode 181 BAUER
-rw-r--r-- 1 vscode vscode 181 KOHL
-rw-r--r-- 1 vscode vscode 181 WOLF
ufer/west:
total 4.0K
-rw-r--r-- 1 vscode vscode 181 ZIEGE
Move 6
repo $ git stash -u
Saved working directory and index state WIP on main: 2045b52 Mittlerer Stand wiederhergestellt.
repo $ git restore -s HEAD~2 ufer
repo $ ll ufer/*
ufer/ost:
total 8.0K
-rw-r--r-- 1 vscode vscode 181 KOHL
-rw-r--r-- 1 vscode vscode 181 WOLF
ufer/west:
total 8.0K
-rw-r--r-- 1 vscode vscode 181 BAUER
-rw-r--r-- 1 vscode vscode 181 ZIEGE
Move 7
repo $ git stash -u
Saved working directory and index state WIP on main: 2045b52 Mittlerer Stand wiederhergestellt.
repo $ git restore -s HEAD~1 ufer
repo $ ll ufer/*
total 16K
-rw-r--r-- 1 vscode vscode 181 BAUER
-rw-r--r-- 1 vscode vscode 181 KOHL
-rw-r--r-- 1 vscode vscode 181 WOLF
-rw-r--r-- 1 vscode vscode 181 ZIEGE
Move 8
repo $ git stash -u
No local changes to save
repo $ git restore -s HEAD~0 ufer
repo $ ll ufer/*
total 16K
-rw-r--r-- 1 vscode vscode 181 BAUER
-rw-r--r-- 1 vscode vscode 181 KOHL
-rw-r--r-- 1 vscode vscode 181 WOLF
-rw-r--r-- 1 vscode vscode 181 ZIEGE