0
0
Gitdevops~20 mins

Why stashing saves work temporarily in Git - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Stash Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What does git stash do with your changes?

You have made changes to files but want to switch branches without committing. What does git stash do with your changes?

AIt uploads your changes to the remote repository without committing.
BIt commits your changes to the current branch automatically.
CIt saves your changes in a temporary area and reverts your working directory to the last commit.
DIt deletes your changes permanently from the working directory.
Attempts:
2 left
💡 Hint

Think about how you can save work without committing it yet.

💻 Command Output
intermediate
2:00remaining
Output of git stash list after stashing changes

You run git stash after modifying some files. What will git stash list show?

Git
git stash

git stash list
ANo stash entries found.
BUntracked files present.
CError: stash list command not found.
Dstash@{0}: WIP on main: <commit-hash> Your last commit message
Attempts:
2 left
💡 Hint

What does git stash list show after you stash changes?

🔀 Workflow
advanced
3:00remaining
Correct sequence to save and restore work using git stash

Arrange the steps in the correct order to save your work temporarily and then restore it later using git stash.

A1,2,3,4
B2,1,3,4
C1,3,2,4
D2,3,1,4
Attempts:
2 left
💡 Hint

Think about saving first, then switching branches, then restoring.

Troubleshoot
advanced
2:00remaining
Why does git stash apply fail with conflicts?

You stashed changes on branch A, switched to branch B, and ran git stash apply. It failed with conflicts. Why?

ABecause the changes in the stash conflict with files on branch B.
BBecause <code>git stash apply</code> only works on the original branch.
CBecause the stash was deleted automatically after switching branches.
DBecause <code>git stash apply</code> requires a commit before applying.
Attempts:
2 left
💡 Hint

Think about what happens if your saved changes clash with current files.

Best Practice
expert
2:30remaining
Why is it better to use git stash instead of committing unfinished work?

Which reason best explains why using git stash is better than committing unfinished work to the repository?

ABecause stashing automatically pushes changes to the remote repository.
BBecause stashing keeps the commit history clean by not adding incomplete work.
CBecause commits cannot be undone once made, but stashes can be deleted.
DBecause stashing merges changes from multiple branches automatically.
Attempts:
2 left
💡 Hint

Think about how your project history looks with many small unfinished commits.