{"thread":{"id":"52010","subject":"Possible bug in git stash with submodule.recurse","startedAt":"2019-10-10T15:26:29Z","lastAt":"2019-10-10T15:26:29Z","messageCount":1,"participants":["Jakob Jarmar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"383803","messageId":"CA+xNDHseTCoD+7Vbb4AG0kt9itXn0Z1Kto0vDjF9bBn+Fuk3TA@mail.gmail.com","threadId":"52010","inReplyTo":null,"subject":"Possible bug in git stash with submodule.recurse","fromName":"Jakob Jarmar","fromEmail":"jakob.j@gmail.com","sentAt":"2019-10-10T15:26:10Z","receivedAt":"2019-10-10T15:26:29Z","isPatch":false,"sender":{"key":"jakob.j@gmail.com","avatar":"https://avatars.githubusercontent.com/u/604850?v=4"},"body":"Hi,\n\nI ran into an issue where git stash seems to be losing modified content\nfrom submodules without warning, if submodule.recurse is true. See\nbelow for an example:\n\n1. enable submodule.recurse:\n\n~ $ git config --global submodule.recurse true\n\n2. create the repo to be used as a submodule:\n\n~ $ git init sub\nInitialized empty Git repository in /home/jakob/sub/.git/\n~ $ cd sub/\n~/sub $ touch sub.txt\n~/sub $ git add sub.txt\n~/sub $ git commit -m initial\n[master (root-commit) 651a90c] initial\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 sub.txt\n~/sub $ cd ..\n\n3. create the main repo, add sub as a submodule:\n\n~ $ git init main\nInitialized empty Git repository in /home/jakob/main/.git/\n~ $ cd main/\n~/main $ touch main.txt\n~/main $ git add main.txt\n~/main $ git submodule add ../sub/\nCloning into '/home/jakob/main/sub'...\ndone.\n~/main $ git commit -m initial\n[master (root-commit) 2f9f4e8] initial\n 3 files changed, 4 insertions(+)\n create mode 100644 .gitmodules\n create mode 100644 main.txt\n create mode 160000 sub\n\n4. make *both* main and sub dirty (if main is clean, stash does nothing):\n\n~/main $ echo changes > main.txt\n~/main $ echo changes > sub/sub.txt\n~/main $ git diff sub/\nSubmodule sub contains modified content\n\n5. git stash and git stash pop:\n\n~/main $ git stash\nSaved working directory and index state WIP on master: 2f9f4e8 initial\n~/main $ git stash pop\nOn branch master\nChanges not staged for commit:\n  (use \"git add <file>...\" to update what will be committed)\n  (use \"git checkout -- <file>...\" to discard changes in working directory)\n\n    modified:   main.txt\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\nDropped refs/stash@{0} (00a38b73407e7e3041c9459ef6d61bc90940b91f)\n~/main $ git diff sub/\n~/main $\n\nAt this point, I can't seem to find any way to retrieve the changes\nmade to sub/sub.txt.\n\nThanks,\nJakob\n"}]}