↑ ↓ select, Enter open, Esc close

Temporarily save local changes with git stash

Caution: This command changes the system. Understand what it does before you run it.

Adjust the values, the command updates live
user@server
git stash push -u -m 'Hotfix test on the server'

Saves modified files and, with -u, also new untracked files in a stash and resets the working directory to the last commit. Useful for quickly running a git pull or switching branches without committing unfinished work. git stash list shows all stashes, and git stash pop brings back the latest one.

Note: Ignored files (for example from .gitignore) are not saved. Restoring can cause conflicts, in which case the stash is kept.

Also searched as

  • git stash including untracked files
  • git pull with local changes
  • save work without committing

Related one-liners

All in Git

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.