Forrest logo
back to the git tool

git-stash:tldr:dddff

git-stash: Stash current changes, including new (untracked) files.
$ git stash -u
try on your machine

The command git stash -u is used to save the changes made to your working directory temporarily without committing them.

Here's what each part of the command means:

  • git stash: This is the main command to save changes in the working directory that are not ready to be committed. It creates a new stash object that stores both tracked and untracked changes.
  • -u or --include-untracked: This is an option that tells Git to include untracked files in the stash. By default, only the changes in tracked files are stashed. The -u flag allows you to stash untracked files as well.

The purpose of using git stash -u is to store your current changes, including both modified and untracked files, so that you can switch to a different branch or perform other operations without committing or losing your progress. Later, you can apply or pop the stash to retrieve your changes and continue working on them.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool