Introduction
Imagine you're a developer working on a time machine project. Suddenly, your future self appears and warns you about a critical bug in the current codebase! You need to quickly save your work-in-progress, fix the bug, and then resume your current task. This challenge will test your Git stash skills in a high-stakes, time-bending scenario!
Stash, Fix, and Resume
Initial State
You are in the ~/project directory. The time-machine directory is a new Git repository with the following files:
main-console.txt(content: "Bug: Temporal Flux Unstable")flux-capacitor.txt(content: "Work in progress")new-feature.txt(content: "Untracked feature")
You can use the git status command to check the current status of the repository.
Tasks
- Stash your current changes, including any untracked files.
- Fix the "critical bug" in the
masterbranch by updating the content ofmain-console.txtto "Fixed: Temporal Flux Stabilized". - Create a new branch from your stashed changes, named
future-upgrades. - Ensure the bug fix from the master branch is also present in the
future-upgradesbranch.
Requirements
- All operations must be performed in the
~/project/time-machinedirectory. - Ensure your original changes (both tracked and untracked) are present in the new branch.
- The bug fix in
main-console.txtmust be present in bothmasterandfuture-upgradesbranches.
Example
After completing the challenge, your repository should look like this:
On the master branch:
main-console.txt (content: "Fixed: Temporal Flux Stabilized")
On the future-upgrades branch:
main-console.txt (content: "Fixed: Temporal Flux Stabilized") ## Contains the bug fix from master
flux-capacitor.txt (content: "Work in progress") ## Original tracked changes
new-feature.txt (content: "Untracked feature") ## Original untracked file
Note: To achieve this state, you'll need to ensure that both branches contain the bug fix while preserving your work-in-progress changes in the future-upgrades branch.
Summary
In this challenge, you've practiced using Git stash in a simulated emergency scenario. You've learned how to quickly save your work-in-progress (including untracked files), switch contexts to fix a critical issue, and then create a new branch from your stashed changes. These skills are crucial for maintaining a smooth workflow when unexpected tasks arise, allowing you to juggle multiple responsibilities without losing your work or breaking your concentration.
Remember, while Git stash is a powerful tool for temporarily storing changes, it's best used for short-term storage. For longer-term work or significant features, creating dedicated branches is often a better approach. Keep practicing these skills, and you'll be well-equipped to handle any time-bending development scenarios that come your way!



