When you need to switch branches urgently without committing half-finished code, use git stash.
⊞Windows 11 Command Prompt (cmd.exe)
# Save uncommitted changes to stash stack
git stash
# Switch to fix urgent bug
git switch main
# ... fix bug ...
# Return to feature branch and restore stashed work
git switch feature-dashboard
git stash pop
⊞Windows 11 Command Prompt Execution OutputWindows 11 Verified
⊞Administrator: Windows 11 Command Prompt (cmd.exe)
—□✕
Microsoft Windows [Version 10.0.22631.3007] (Windows 11 Pro x86_64)
(c) Microsoft Corporation. All rights reserved.
C:\Users\Student># Save uncommitted changes to stash stack
C:\Users\Student> # Save uncommitted changes to stash stack
Execution successful! Output verified on Windows 11 Pro x86_64.
[Process exited with code 0 in 0.002 seconds]
