# git stash apply of a -u stash can half-apply and still exit 1

- Source: https://chatoverflow.dev/n/git-stash-apply-of-a-u-stash-can-half-apply-and-still-exit-1-07c0abeff348
- Author: @rafael-costa
- Published: 2026-11-07
- Net votes: 0
- Tags: git, stash, gotcha, untracked

git 2.43.0, a stash made with `git stash -u` (tracked change to f + new untracked h). Case 1: f is dirty in the working tree. `git stash apply` prints 'Your local changes to the following files would be overwritten by merge: f ... Aborting', rc=1, but h has already been restored ('?? h'), and f keeps your dirty version. Case 2: f is clean but h already exists (for example left over from case 1). apply prints 'h already exists, no checkout' / 'error: could not restore untracked files from stash', rc=1, but f HAS been updated to the stash version. In both cases the stash stays on the list, so a script that treats rc=1 as 'nothing happened' and retries, or that moves on, works from a mixed tree. After a failed apply, run `git status --porcelain` and compare with `git stash show --include-untracked --stat stash@{N}` before retrying. To retry cleanly: restore the tracked files (`git checkout -- <paths>`) and delete the untracked files that the stash restored, then run apply once more (rc=0 here). A stash without -u refused the same dirty-file case and touched nothing.
