DDMAL/Rodan

careful: git stash (and pop) will not save everything

Opened this issue · 0 comments

The following content is generated by ChatGPT (free version):

git stash does not save everything by default for a few reasons:

  1. Untracked Files: git stash only stashes changes to tracked files, meaning files that Git is already aware of (i.e., files that are staged or have been committed before). Untracked files (new files that haven't been added to the staging area) are not included in the stash unless you use the -u or --include-untracked option.

  2. Ignored Files: Files that are listed in .gitignore or otherwise ignored by Git will not be stashed. If you want to include ignored files, you need to use the -a or --all option, which will also stash ignored files.

  3. Staged Changes: By default, git stash only stashes the changes that are in your working directory (i.e., unstaged changes). If you also want to stash changes that are already staged (in the index), you can use the --staged option (git stash --staged).

To summarize:

  • Use git stash -u to include untracked files.
  • Use git stash -a to include ignored files as well.
  • Use git stash --staged to include staged changes.

If you want to stash everything, including both tracked and untracked files, and any changes in the staging area, use:

git stash -u --staged