threads / discuss / 50064

bugreport: git checkout --recurse-submodules overwrites unstaged changes

Subject: bugreport: git checkout --recurse-submodules overwrites unstaged changes

## tl;dr

One message between Dec 19, 2018 and Dec 19, 2018.

replies: 0people: 1as markdown or json

Petr Gregor· Dec 19, 2018, 07:25 UTC · lore

Hello, I believe we found a reproducible bug in git checkout --recurse-submodules command. Documentation says, that this command should not overwrite unstaged changes in submodules unless -f is given. In reality local changes can be accidentally overwritten even without -f flag.

I reproduced the issue with git version 2.20.1 like this:

git init git submodule add https://github.com/Gregy/znapzend-debian submodule git add . && git commit -m 'first' git checkout -b 'newbranch' (cd submodule && git checkout a3a7b0) git add . && git commit -m 'set new branch to different submodule commit' echo 'test' > submodule/debian/compat #create an unstaged change git checkout master --recurse-submodules #my change is overwritten

Thank you for maintaining git, it is awesome!
Petr Gregor

← back to recent threads