Lesson06
intermediateShelve Work with git stash
Goal
Put unfinished work aside, switch branches, and bring the work back later.
You are halfway through a profile page on feature/profile when someone asks you to check something on main. Your edit to profile.js is not ready to commit, and main has a different version of that file, so Git will not let you switch.
Shelve the work, visit main, come back, and pick up exactly where you were.
Objectives
0/5- Your unfinished work is in the stash. (Current objective)
- You are on
main. (Not started) - You are back on
feature/profile. (Not started) profile.jshas your unfinished edit again. (Not started)- The stash is empty again. (Not started)
Your task nowStep 1 of 5
Your unfinished work is in the stash.
Need help?
Reference
Shelving work
$ git stash
Saved working directory and index state WIP on feature/profile: 1a2b3c4 Add profile pageYour uncommitted changes are saved in a stash entry and the files go back to the last commit, so switching branches is safe again. Untracked files stay put unless you add -u.
Getting work back
git stash pop
- Reapplies the newest entry
- Removes it from the stash list
git stash apply
- Reapplies the newest entry
- Keeps it in the list (drop it later with
git stash drop)
Preparing your workspace…
Repository Graph
Click a commit to inspect it
Working Tree
Not a Git repository yet
No unstaged changes
Your working tree matches the staging area.
Staging Area
Files prepared for the next commit
No staged changes
Use git add to prepare files for your next commit.
Repository
Committed history
No commits yet
Use git commit to record staged changes.
