[FR] Allow `git stash create` to include untracked changes
- From
- dev@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.