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

[FR] Allow `git stash create` to include untracked changes

From
Ddev@kipras.org <dev@kipras.org>
Date
Oct 26, 2019, 14:38 UTC
Message-ID
<d02ddc0db596771820b0cfdfae5b1504@kipras.org>
Hello,

TL;DR: Would it be possible for `git stash create` to include untracked changes (probably the same way `git stash push --include-untracked` does)?

---
I'm having some trouble with `git stash create`.

Currently, in my script (https://github.com/sarpik/git-backup), I essentially want to create a stash from untracked changes, create a branch from the stash, push the branch to a remote repository & pop the stash back, while keeping the backup branch. A remote stash, if you may.

I'm able to do this with regular `git stash push --include-untracked` and `git stash pop` commands, but there're some issues I've encountered and I believe that this is not the optimal solution. This could be solved with `git stash create`, but it's unable to (as far as I know) create the stash with untracked/all changes.

Once again: Would it be possible for `git stash create` to include untracked changes (probably the same way `git stash push --include-untracked` does)?

---
The issues I've so far encountered were:

Say I'm in an untracked directory. If I run `git stash push --include-untracked` and stay in this untracked directory, which actually does not exist anymore, and then run `git stash pop`, I get fatal errors and I'm unable to do anything else:

fatal: Unable to read current working directory: No such file or directory

(please see https://github.com/sarpik/git-backup/issues/10 and specifically, https://github.com/sarpik/git-backup/issues/10#issuecomment-546599631)

This could probably be solved by `cd`ing up until I'm inside the same directory where `.git/` folder is placed and only then running `git stash push --include-untracked` and `git stash pop`.

Even then, this approach still kind of sucks, because you're still temporarily stashing user's changes. I'd like to avoid this and `git stash create` seems like the perfect solution, if only it could include untracked changes.

Thank you very much - please let me know if there's anything else I could help with.

Next: Junio C Hamano
Message 1 of 5 in “[FR] Allow `git stash create` to include untracked changes”
  1. dev@kipras.orgOct 26, 2019
  2. Junio C HamanoOct 28, 2019
  3. Kipras MelnikovasOct 28, 2019
  4. Johannes SchindelinOct 29, 2019
  5. Thomas GummererOct 31, 2019

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.