# Possible bug with checkout and submodules

4 messages from 2021-10-16 to 2021-10-17. Participants: Adam Hutchings, brian m. carlson, Philippe Blain.
Thread: https://gitlist.dev/t/56726

## Adam Hutchings, 2021-10-16 18:44

Subject: Possible bug with checkout and submodules
Message-ID: <CADTYju0PpHHG1=S3N4MDWk5yZqb5t_KUhiDvZ_2i-vXFUT_LDw@mail.gmail.com>
URL: https://gitlist.dev/e/CADTYju0PpHHG1%3DS3N4MDWk5yZqb5t_KUhiDvZ_2i-vXFUT_LDw%40mail.gmail.com

```
Hi,

I may have found a bug in Git but I'm not sure if it's intentional or not. I

checked out to a new branch to test a PR on my repo, and the PR added a

submodule. I init'ed and updated the submodule, and when I was done testing, I

went back to my main branch. However, it did not remove the submodule, and

produced this message:


ˋˋˋ

$ git checkout main

warning: unable to rmdir 'glfw': Directory not empty

Switched to branch 'main'

$

ˋˋˋ


A friend of mine has managed to reproduce this behavior. We believe the expected

outcome is to remove the submodule folder, but this does not seem to happen. Is

this intentional?


Best,



Adam Hutchings

```

## brian m. carlson, 2021-10-16 18:52

Subject: Re: Possible bug with checkout and submodules
Message-ID: <YWsffmtRQKQGxkiR@camp.crustytoothpaste.net>
URL: https://gitlist.dev/e/YWsffmtRQKQGxkiR%40camp.crustytoothpaste.net
In-Reply-To: <CADTYju0PpHHG1=S3N4MDWk5yZqb5t_KUhiDvZ_2i-vXFUT_LDw@mail.gmail.com>

```
On 2021-10-16 at 18:44:04, Adam Hutchings wrote:
> Hi,
> 
> I may have found a bug in Git but I'm not sure if it's intentional or not. I
> 
> checked out to a new branch to test a PR on my repo, and the PR added a
> 
> submodule. I init'ed and updated the submodule, and when I was done testing, I
> 
> went back to my main branch. However, it did not remove the submodule, and
> 
> produced this message:
> 
> 
> ˋˋˋ
> 
> $ git checkout main
> 
> warning: unable to rmdir 'glfw': Directory not empty
> 
> Switched to branch 'main'
> 
> $
> 
> ˋˋˋ
> 
> 
> A friend of mine has managed to reproduce this behavior. We believe the expected
> 
> outcome is to remove the submodule folder, but this does not seem to happen. Is
> 
> this intentional?

This is intentional.  It may be that the submodule has data that's
ignored, it could have local changes, or it could have additional
unpushed history, any of which would probably be data users might not
want to lose.  As a result, we don't remove the directory unless the
user has run "git submodule deinit".
-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA

```

## Adam Hutchings, 2021-10-16 20:32

Subject: Re: Possible bug with checkout and submodules
Message-ID: <CADTYju16KTNP_4cLs=Q=19r72ECgYnjLv=Y3nCNhX1fs1P-vxQ@mail.gmail.com>
URL: https://gitlist.dev/e/CADTYju16KTNP_4cLs%3DQ%3D19r72ECgYnjLv%3DY3nCNhX1fs1P-vxQ%40mail.gmail.com
In-Reply-To: <YWsffmtRQKQGxkiR@camp.crustytoothpaste.net>

```
OK, thank you!

On Sat, Oct 16, 2021 at 11:52 AM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> On 2021-10-16 at 18:44:04, Adam Hutchings wrote:
> > Hi,
> >
> > I may have found a bug in Git but I'm not sure if it's intentional or not. I
> >
> > checked out to a new branch to test a PR on my repo, and the PR added a
> >
> > submodule. I init'ed and updated the submodule, and when I was done testing, I
> >
> > went back to my main branch. However, it did not remove the submodule, and
> >
> > produced this message:
> >
> >
> > ˋˋˋ
> >
> > $ git checkout main
> >
> > warning: unable to rmdir 'glfw': Directory not empty
> >
> > Switched to branch 'main'
> >
> > $
> >
> > ˋˋˋ
> >
> >
> > A friend of mine has managed to reproduce this behavior. We believe the expected
> >
> > outcome is to remove the submodule folder, but this does not seem to happen. Is
> >
> > this intentional?
>
> This is intentional.  It may be that the submodule has data that's
> ignored, it could have local changes, or it could have additional
> unpushed history, any of which would probably be data users might not
> want to lose.  As a result, we don't remove the directory unless the
> user has run "git submodule deinit".
> --
> brian m. carlson (he/him or they/them)
> Toronto, Ontario, CA

```

## Philippe Blain, 2021-10-17 00:30

Subject: Re: Possible bug with checkout and submodules
Message-ID: <0d8ade7b-e5af-88ec-3e33-96d6c356b714@gmail.com>
URL: https://gitlist.dev/e/0d8ade7b-e5af-88ec-3e33-96d6c356b714%40gmail.com
In-Reply-To: <YWsffmtRQKQGxkiR@camp.crustytoothpaste.net>

```
Hi Adam,

Le 2021-10-16 à 14:52, brian m. carlson a écrit :
> On 2021-10-16 at 18:44:04, Adam Hutchings wrote:
>> Hi,
>>
>> I may have found a bug in Git but I'm not sure if it's intentional or not. I
>>
>> checked out to a new branch to test a PR on my repo, and the PR added a
>>
>> submodule. I init'ed and updated the submodule, and when I was done testing, I
>>
>> went back to my main branch. However, it did not remove the submodule, and
>>
>> produced this message:
>>
>>
>> ˋˋˋ
>>
>> $ git checkout main
>>
>> warning: unable to rmdir 'glfw': Directory not empty
>>
>> Switched to branch 'main'
>>
>> $
>>
>> ˋˋˋ
>>
>>
>> A friend of mine has managed to reproduce this behavior. We believe the expected
>>
>> outcome is to remove the submodule folder, but this does not seem to happen. Is
>>
>> this intentional?
> 
> This is intentional.  It may be that the submodule has data that's
> ignored, it could have local changes, or it could have additional
> unpushed history, any of which would probably be data users might not
> want to lose.  As a result, we don't remove the directory unless the
> user has run "git submodule deinit".
> 

... or unless you run 'git checkout --recurse-submodules', or just
'git checkout' and you have 'submodule.recurse' set to true in your configuration.

Cheers,
Philippe.

```
