{"thread":{"id":"47906","subject":"removed submodules shown as untracked when switching branches","startedAt":"2018-02-22T20:46:19Z","lastAt":"2018-02-23T00:41:57Z","messageCount":3,"participants":["Mike Friedrich","Stefan Beller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"339974","messageId":"6add3709b4eb469bb7c8d6319637b53a@USEPRDEX2.corp.kns.com","threadId":"47906","inReplyTo":null,"subject":"removed submodules shown as untracked when switching branches","fromName":"Mike Friedrich","fromEmail":"mfriedrich@kns.com","sentAt":"2018-02-22T20:26:27Z","receivedAt":"2018-02-22T20:46:19Z","isPatch":false,"sender":{"key":"mfriedrich@kns.com","avatar":null},"body":"Hi,\n\nWhen switching clean branches I see untracked files appearing where I expect to see \"nothing to commit, working tree clean\".\nThis happens when submodules get removed on one branch but its present in another.\nI expect git to either not mark the submodule in git status as untracked or git to remove the submodule as it would for ordinary tracked files which do not exist on a branch anymore.\n\nTested on Windows with: git version 2.15.1.windows.2\nTested on Ubuntu Linux with same output: git version 2.14.1\n\nTest:\n    git init test\n    git init submodule\n    cd submodule\n    touch file.txt\n    git add file.txt\n    git commit -m \"test\"\n    cd ../test\n    touch initial.txt\n    git add initial.txt\n    git commit -m \"initial\"\n    git checkout -b develop\n    git status\n    #On branch develop\n    #nothing to commit, working tree clean\n\n    git submodule add ../submodule sub\n    git add sub\n    git commit -m \"submodule added\"\n    git status\n    #On branch develop\n    #nothing to commit, working tree clean\n\n    git checkout master\n    git status\n    #On branch master\n    #Untracked files:\n    #  (use \"git add <file>...\" to include in what will be committed)\n    #\n    #        sub/\n    #\n    #nothing added to commit but untracked files present (use \"git add\" to track)\n    # expected: nothing to commit, working tree clean\n\n    git submodule update\n    # (no output)\n    git submodule\n    # (no output)\n    git status\n    #On branch master\n    #Untracked files:\n    #  (use \"git add <file>...\" to include in what will be committed)\n    #\n    #        sub/\n    #\n    #nothing added to commit but untracked files present (use \"git add\" to track)\n    # expected: nothing to commit, working tree clean\n\n    git clean -dfx\n    #Skipping repository sub/\n\nBest Regards,\nMike Friedrich\n\n\n________________________________\n\nThis email is non-binding, is subject to contract, and neither Kulicke and Soffa Industries, Inc. nor its subsidiaries (each and collectively “K&S”) shall have any obligation to you to consummate the transactions herein or to enter into any agreement, other than in accordance with the terms and conditions of a definitive agreement if and when negotiated, finalized and executed between the parties. This email and all its contents are protected by International and United States copyright laws. Any reproduction or use of all or any part of this email without the express written consent of K&S is prohibited.\n"},{"id":"339990","messageId":"CAGZ79kYS_yJs2uFqLDwCgq4W0HrnMxZcCx8-dTXYf3hpPZYWFg@mail.gmail.com","threadId":"47906","inReplyTo":"6add3709b4eb469bb7c8d6319637b53a@USEPRDEX2.corp.kns.com","subject":"Re: removed submodules shown as untracked when switching branches","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-02-22T23:53:23Z","receivedAt":"2018-02-22T23:53:31Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Feb 22, 2018 at 12:26 PM, Mike Friedrich <mfriedrich@kns.com> wrote:\n\n>     git submodule add ../submodule sub\n>     git add sub\n>     git commit -m \"submodule added\"\n>\n>     git checkout master\n\nThe original behavior of checkout is to ignore submodules, hence it\nwill be left alone.\nCan you retry this recipe with --recurse-submodules given to checkout.\n(Or rather run \"git config submodule.recurse true\" once)\n\nThanks,\nStefan\n"},{"id":"339991","messageId":"ed3eddb3da05471c8195326043f46740@USEPRDEX2.corp.kns.com","threadId":"47906","inReplyTo":"CAGZ79kYS_yJs2uFqLDwCgq4W0HrnMxZcCx8-dTXYf3hpPZYWFg@mail.gmail.com","subject":"RE: removed submodules shown as untracked when switching branches","fromName":"Mike Friedrich","fromEmail":"mfriedrich@kns.com","sentAt":"2018-02-23T00:41:35Z","receivedAt":"2018-02-23T00:41:57Z","isPatch":false,"sender":{"key":"mfriedrich@kns.com","avatar":null},"body":"Thank You. This is interesting. There seems to be also a config option submodule.recurse. I did not know that these options have such an effect on the checkout command.\n\nBest Regards, Mike\n\n-----Original Message-----\nFrom: Stefan Beller [mailto:sbeller@google.com]\nSent: Thursday, February 22, 2018 6:53 PM\nTo: Mike Friedrich <mfriedrich@kns.com>\nCc: git@vger.kernel.org\nSubject: Re: removed submodules shown as untracked when switching branches\n\nOn Thu, Feb 22, 2018 at 12:26 PM, Mike Friedrich <mfriedrich@kns.com> wrote:\n\n>     git submodule add ../submodule sub\n>     git add sub\n>     git commit -m \"submodule added\"\n>\n>     git checkout master\n\nThe original behavior of checkout is to ignore submodules, hence it will be left alone.\nCan you retry this recipe with --recurse-submodules given to checkout.\n(Or rather run \"git config submodule.recurse true\" once)\n\nThanks,\nStefan\n\n________________________________\n\nThis email is non-binding, is subject to contract, and neither Kulicke and Soffa Industries, Inc. nor its subsidiaries (each and collectively “K&S”) shall have any obligation to you to consummate the transactions herein or to enter into any agreement, other than in accordance with the terms and conditions of a definitive agreement if and when negotiated, finalized and executed between the parties. This email and all its contents are protected by International and United States copyright laws. Any reproduction or use of all or any part of this email without the express written consent of K&S is prohibited.\n"}]}