git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git stash push -u deletes untracked files

From
Hosam Aly Mahmoud <hosamaly6@gmail.com>
Date
Apr 2, 2018, 16:07 UTC
Message-ID
<CAJA-u1okS1GO8+mHGbz23cs0CRt7wQAPHHsnvmZnZe4ZOf2VqQ@mail.gmail.com>
Hi,

Using Git 2.16.3 on MacOS 10.13.3, running `git stash push --include-untracked` deletes the untracked files specified in its arguments and creates an empty stash commit.

In the example below, I create a repository with a single file and a single commit. Then I create two untracked files and push one of them to the stash. Although I get an error, an empty stash commit is generated and the specified file is deleted.

``` $ git init . && touch README && git commit -m "README" $ touch my-file my-other-file $ git status On branch master Untracked files: my-file my-other-file

nothing added to commit but untracked files present $ git stash push -u my-file Saved working directory and index state WIP on master: e89afc6 README fatal: pathspec 'my-file' did not match any files error: unrecognized input $ git status On branch master Untracked files: my-other-file

nothing added to commit but untracked files present $ git stash list stash@{0}: WIP on master: e89afc6 README $ git stash show $ $ ls README my-other-file ```

I tested this using git built from the latest commit on master at the time of writing (c2a499e6c31ed613a606ffdeb5bb74ab41e9a586) and got the same results. Could you please check it out?

Thank you,
Hosam Aly
Next: Thomas Gummerer
Message 1 of 2 in “git stash push -u deletes untracked files”
  1. Hosam Aly MahmoudApr 2, 2018
  2. Thomas GummererApr 2, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.