I am using the --intent-to-add
option with git add
to easily add files using git commit -a
. However, it seems like this confuses git stash
. For example:
git init
touch a
git add a
git commit -m 1
touch b
git add --intent-to-add b
git stash --include-untracked
gives output from git stash
:
error: Entry 'b' not uptodate. Cannot merge.
Cannot save the current worktree state
Why does this happen? Can it be fixed?
Given a git stash
followed by git stash pop
will clear the index anyway, I would start with git reset --keep
to clear the index. (With --keep
, this won't change your local files or your commits, it only clears the index.)
git reset --keep
git stash --include-untracked
Once you've done the stuff you needed the stash for, you have to redo git add --intent-to-add b
since you undid it with the reset:
git stash pop
git add --intent-to-add b
As for why this happens in the first place, I don't know. Seems like a bug to me... You can stash a regular git add
, afterall.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With