120. Stash Work, Fix Bug, Restore and Update
Beginner Mode
Start your terminal to use beginner mode.
Scenario
Uncommitted changes on feature-ui prevent you from switching branches to fix a critical bug on main.
Task
Stash local changes to clean the working directory with message WIP: UI improvements. Switch to a new branch hotfix-auth to implement the fix, then merge it into main. Finally, rebase feature-ui against the updated main and restore your stashed changes.
Changes in hotfix-auth branch are below:
echo "Fixing critical bug" >> src/auth.js
git commit -m "Fix critical authentication bug"
Example
Bash
# Before (Switch blocked)
error: Your local changes to the following files would be overwritten by checkout:
src/ui.js
Please commit your changes or stash them before you switch branches.
# After (Updated and Restored)
$ git log --oneline -1 main
a1b2c3d Fix critical authentication bug
$ git status
On branch feature-ui
Changes not staged for commit:
modified: src/ui.js
Terminal requires a larger screen
Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.
Linux Terminal Environment
Write and execute your solution in the terminal below.
Essential
SQL 0/33
Git 0/15
Spark 0/20
Snowflake 0/22
Python 0/24
Need more practice in this area? Explore more questions →
IBM
TCS
X
Accenture
Adobe
Google
LinkedIn
Samsung
Datadog
Wix
Dropbox
Meta
OpenAI
Hulu
Uber
DoorDash
Anthropic
Amazon
ActivisionBlizzard
Vercel
Crypto.Com
Zscaler
DeutscheBank
Apple
GoDaddy
BMW
PayPal
Snowflake
AMD
Twilio
Atlassian
JPMorgan
NVIDIA
Databricks
Coinbase
Cisco
Robinhood
Twitter
Microsoft
Palantir
Netflix
VMware
Cloudflare
Stripe
Capital One
Splunk
Intel
SAP
Tesla
GitHub
JaneStreet
Bloomberg
Salesforce
Elastic
CGI
UBS
GitLab
Ubisoft
Slack
Nintendo
EY
Kayak
Lyft
Airbnb
Walmart
Revolut
Visa
Okta
HashiCorp
Instacart
Mastercard