I earlier ran git stash push -u ...
to include an untracked file in the stash. Now, I've confirmed that this stash, stash@{2}
, includes this untracked file (and tracked file changes). But, when I run git stash apply 2
, only the tracked files get applied. (note: there were a couple of merge conflicts with some of the tracked files)
I didn't change any directory structure or replace this untracked file since this stash, so it should be able to be easily placed back where it was.
Why isn't the untracked file getting applied?
Thanks for any help!
--
Here, I applied the stash:
$ git stash apply 2
Auto-merging <file1>
CONFLICT (content): Merge conflict in <file1>
Auto-merging <file2>
CONFLICT (content): Merge conflict in <file2>
The untracked file is missing at this point, but I resolve the conflicts, then run:
$ git restore --staged .
The stash apply has been completed, but the untracked file is still missing.
Update
According to this article, it seems that this could possibly be a bug introduced between Git 2.24
and 2.33
(and git --version
tells me I'm using 2.34.1
). However, I'm not sure if this is very likely since I feel like this problem would have more attention, given that git 2.33
apparently released almost 2 years ago (Aug 16, 2021
).
Answer:
It turns out this was a bug in git
2.34.1
. Upgrading to2.41.0
worked for me.Exactly what I did to resolve:
I was using WSL (Ubuntu 22.04 LTS), so in order to upgrade git past
2.34.1
, I followed this article's guide, using the following commands, which left me withgit 2.41.0
:Since my working directory and staging area were clean before the unfinished
git stash apply
, I cleaned it with the following:Then, back to my original goal, I did the following, and it worked perfectly as expected: