Git stash
Imagine Developer A is working on a new feature on thedevelop branch. Developer B suddenly reports a critical bug that must be fixed immediately on main. Developer A’s feature isn’t finished yet, so they don’t want to commit it — but they need a clean working area to switch branches.
This is exactly what git stash is for. It temporarily shelves (stashes) changes so you can switch context and come back to your work later.
Stashes pile up like a queue (FIFO). You can keep pushing changes onto the stash and apply or pop them when you’re ready.
Stash commands
stash push
When you rungit stash (or git stash push), Git saves your current working directory and staged changes to the stash stack, leaving you with a clean working area.