All local changes were autostashed, but git still complains that my changes would be overwritten. Why?

35 Views Asked by At

This is error message:

$ git rebase -v --autostash --rebase-merges -i
Created autostash: 342ab280
Changes from 9f08a6b01a5da2aa9d53532dff5a4fb2e5fd80a3 to 9f08a6b01a5da2aa9d53532dff5a4fb2e5fd80a3:
error: Your local changes to the following files would be overwritten by checkout:
    aws/image.pkr.hcl
Please commit your changes or stash them before you switch branches.
Aborting
Applied autostash.
error: could not detach HEAD

Why I get this error message when I do not have any local changes? All local changes are autostashed.

UPD If I manually stash local changes and run git rebase command two times, then everything works as expected:

$ alias grb
alias grb='GIT_EDITOR='\''code -w'\'' git rebase -v --autostash --rebase-merges -i'

$ git stash save
Saved working directory and index state WIP on tools-for-cluster: 041bc8a3 asdf

$ grb 60b3a2e966045901bb42b826bb77c70d8a0bc142^
Changes from 9f08a6b01a5da2aa9d53532dff5a4fb2e5fd80a3 to 9f08a6b01a5da2aa9d53532dff5a4fb2e5fd80a3:
error: Your local changes to the following files would be overwritten by checkout:
    aws/image.pkr.hcl
Please commit your changes or stash them before you switch branches.
Aborting
error: could not detach HEAD

$ grb 60b3a2e966045901bb42b826bb77c70d8a0bc142^
Changes from 9f08a6b01a5da2aa9d53532dff5a4fb2e5fd80a3 to 9f08a6b01a5da2aa9d53532dff5a4fb2e5fd80a3:
Rebasing (1/4)
Rebasing (2/4)
Rebasing (3/4)
Rebasing (4/4)
Successfully rebased and updated refs/heads/tools-for-cluster.
0

There are 0 best solutions below