diff --git a/levels/sequence b/levels/sequence index 49acab7..9a16a07 100644 --- a/levels/sequence +++ b/levels/sequence @@ -1,3 +1,4 @@ +stash index time-machine low-level diff --git a/levels/stash/sequence b/levels/stash/sequence new file mode 100644 index 0000000..9dd02f7 --- /dev/null +++ b/levels/stash/sequence @@ -0,0 +1,5 @@ +stash +stash-pop +stash-clear +stash-branch +stash-merge diff --git a/levels/stash/stash b/levels/stash/stash new file mode 100644 index 0000000..0a135f4 --- /dev/null +++ b/levels/stash/stash @@ -0,0 +1,45 @@ +title = Stashing +cards = checkout commit-auto merge reset-hard + +[description] + +You will encounter situations in which you are working on your project but you need to +put your current changes aride temporarily. To do so, you can use the stash function. Use + git stash push +to add your current changes to the stash stack. + +--- +tipp1 +--- +tipp2 +--- +tipp3 + +[setup] + +echo "Apple Pie:" > recipe + +git add . +git commit -m "creating a recipe" + +echo "- 4 Apples" >> recipe + +git add . +git commit -m "Adding ingredients" + +echo "- 500g Flour" >> recipe + +git checkout main + +[win] + +# Did you stash the current changes? +test "$(git stash list | wc -l)" -ge 1 + +[actions] + + + +[congrats] + +Nice stash you got there! :) diff --git a/levels/stash/stash-branch b/levels/stash/stash-branch new file mode 100644 index 0000000..fa3f9fc --- /dev/null +++ b/levels/stash/stash-branch @@ -0,0 +1,50 @@ +title = Branch from stash +cards = checkout commit-auto merge reset-hard + +[description] + +If you want to keep your changes but they don't belong to the main branch, you can easily +create a new branch from your stashed shanges. Just use + git stash branch +If you just want to use the latest stash entry, you can leave the option empty. + +Create a new branch from the stashed changes! + +Clear you stash stack! + +--- +tipp1 +--- +tipp2 +--- +tipp3 + +[setup] + +echo "Apple Pie:" > recipe + +git add . +git commit -m "creating a recipe" + +echo "- 4 Apples" >> recipe + +git add . +git commit -m "Adding ingredients" + +echo "- 500g Flour" >> recipe +git stash push + +git checkout main + +[win] + +# Did you clear your stash stack? +test "$(git branch --list| wc -l)" -ge 2 + +[actions] + + + +[congrats] + +All clear! :) diff --git a/levels/stash/stash-clear b/levels/stash/stash-clear new file mode 100644 index 0000000..00e110c --- /dev/null +++ b/levels/stash/stash-clear @@ -0,0 +1,57 @@ +title = Clear the Stash +cards = checkout commit-auto merge reset-hard + +[description] + +If you want to inspect your stash stack, use the command + git stash list + +Oh, you don't want to keep your stashed changes? There are way too many? Then go ahead and clear the stack with + git stash clear +If you only want to discard a certain stash entry, you can use + git stash drop + +Clear you stash stack! + +--- +tipp1 +--- +tipp2 +--- +tipp3 + +[setup] + +echo "Apple Pie:" > recipe + +git add . +git commit -m "creating a recipe" + +echo "- 4 Apples" >> recipe + +git add . +git commit -m "Adding ingredients" + +echo "- 500g Flour" >> recipe +git stash push + +echo "- 200g Sugar" >> recipe +git stash push + +echo "- Pinch of Salt" >> recipe +git stash push + +git checkout main + +[win] + +# Did you clear your stash stack? +test "$(git stash list | wc -l)" -eq 0 + +[actions] + + + +[congrats] + +All clear! :) diff --git a/levels/stash/stash-merge b/levels/stash/stash-merge new file mode 100644 index 0000000..b11fed5 --- /dev/null +++ b/levels/stash/stash-merge @@ -0,0 +1,53 @@ +title = Merging popped stash +cards = checkout commit-auto merge reset-hard + +[description] + +When you want to reapply your changes but you already continued working on your file, you might get +a merge conflict! Let's practise this situation. +Pop the changes from the stash with + git stash pop +and resolve the merge conflict. Commit the resolved changes and clear the stash stack afterwards. + +--- +tipp1 +--- +tipp2 +--- +tipp3 + +[setup] + +echo "Apple Pie:" > recipe + +git add . +git commit -m "creating a recipe" + +echo "- 4 Apples" >> recipe + +git add . +git commit -m "Adding ingredients" + +echo "- 500g Flour" >> recipe + +git stash push + +echo "- Pinch of Salt" >> recipe + +git checkout main + +[win] + +# Did you resolve the confict and commit? +{ git show HEAD | grep "Flour"; } && { git show HEAD | grep "Salt"; } + +# Did you clear stash stack? +test "$(git stash list | wc -l)" -eq 0 + +[actions] + + + +[congrats] + +Yay, you got your changes back! :) diff --git a/levels/stash/stash-pop b/levels/stash/stash-pop new file mode 100644 index 0000000..5ac12d5 --- /dev/null +++ b/levels/stash/stash-pop @@ -0,0 +1,46 @@ +title = Pop from Stash +cards = checkout commit-auto merge reset-hard + +[description] + +When you stashed your changes and you want to apply them back to your current working directory, you can use + git stash pop +This will remove the changes from the stash stack. If you also want to keep the changes on the stash stack, use + git stash apply + +--- +tipp1 +--- +tipp2 +--- +tipp3 + +[setup] + +echo "Apple Pie:" > recipe + +git add . +git commit -m "creating a recipe" + +echo "- 4 Apples" >> recipe + +git add . +git commit -m "Adding ingredients" + +echo "- 500g Flour" >> recipe + +git stash push +git checkout main + +[win] + +# Did you pop the changes from the stash stack? +test "$(git stash list | wc -l)" -eq 0 + +[actions] + + + +[congrats] + +Yay, you got your changes back! :)