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

git stash push/save/create all return exit code 0, even if no object was created

From
ΣΝΣταύρος Ντέντος <stdedos@gmail.com>
Date
Mar 22, 2020, 15:09 UTC
Message-ID
<CAHMHMxW=muHe5qqndtdzR_md6KFQqwEonko-2gXC_q973JgB5w@mail.gmail.com>
Hello there,

I am trying to run a `git checkout` command on a repository, without the possibility of getting any error message about files interfering with the checkout process. I thought a safe way to do this was to run `git-stash`, similarly to `rebase.autoStash = true`

However, I find two issues with those:
1) Exit code is 0, even if no object/stash was created.
It feels weird to parse stdout/stderr to decide "what happened".
2) `git stash create` (which sounds more like what I need), does not
clear what it was stored.
I can "take the pain" of printing the object-sha1 to be traceable if
something happens (even though I would prefer more if it was
"securely" stored in `refs/stash` i.e. `git stash push`), but then
`git stash` won't clean what it just stored.
Is the solution to also run `git reset --hard` there?

With regards, Ntentos Stavros

Next: Junio C Hamano
Message 1 of 3 in “git stash push/save/create all return exit code 0, even if no object was created”
  1. Σταύρος ΝτέντοςMar 22, 2020
  2. Junio C HamanoMar 22, 2020
  3. Σταύρος ΝτέντοςMar 22, 2020

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.