mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-24 16:20:08 +01:00
stashing
This commit is contained in:
parent
82b8e8f458
commit
9109394271
7 changed files with 257 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
stash
|
||||||
index
|
index
|
||||||
time-machine
|
time-machine
|
||||||
low-level
|
low-level
|
||||||
|
|
5
levels/stash/sequence
Normal file
5
levels/stash/sequence
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
stash
|
||||||
|
stash-pop
|
||||||
|
stash-clear
|
||||||
|
stash-branch
|
||||||
|
stash-merge
|
45
levels/stash/stash
Normal file
45
levels/stash/stash
Normal file
|
@ -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! :)
|
50
levels/stash/stash-branch
Normal file
50
levels/stash/stash-branch
Normal file
|
@ -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 <branchname> <stash>
|
||||||
|
If you just want to use the latest stash entry, you can leave the <stash> 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! :)
|
57
levels/stash/stash-clear
Normal file
57
levels/stash/stash-clear
Normal file
|
@ -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 <stash>
|
||||||
|
|
||||||
|
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! :)
|
53
levels/stash/stash-merge
Normal file
53
levels/stash/stash-merge
Normal file
|
@ -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! :)
|
46
levels/stash/stash-pop
Normal file
46
levels/stash/stash-pop
Normal file
|
@ -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! :)
|
Loading…
Reference in a new issue