# Git mv -- submodule -- recursive

4 messages from 2016-06-27 to 2016-06-27. Participants: Bart Bogaerts, Stefan Beller.
Thread: https://gitlist.dev/t/42721

## Bart Bogaerts, 2016-06-27 06:01

Subject: Git mv -- submodule -- recursive
Message-ID: <CAOG-3GJdH5q9fdj+7zdEv-UUZMTAnunZu1PRJYjFNV360r6+sQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAOG-3GJdH5q9fdj%2B7zdEv-UUZMTAnunZu1PRJYjFNV360r6%2BsQ%40mail.gmail.com

```
With a repo structured as follows

main-files
|- submod
    |- subsubmodule

git mv submod newlocation

does not do what it is supposed to do. It actually breaks the git repository.
It can be fixed easily.
A complete description of the bug, including a workaround, can be found on
http://stackoverflow.com/q/32782382/2274140

-- 
Bart Bogaerts

```

## Stefan Beller, 2016-06-27 16:57

Subject: Re: Git mv -- submodule -- recursive
Message-ID: <CAGZ79kYKBxL4xLyySALBv_-gqkss9_iCk-qSc4T7u7fKDMOFWw@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kYKBxL4xLyySALBv_-gqkss9_iCk-qSc4T7u7fKDMOFWw%40mail.gmail.com
In-Reply-To: <CAOG-3GJdH5q9fdj+7zdEv-UUZMTAnunZu1PRJYjFNV360r6+sQ@mail.gmail.com>

```
On Sun, Jun 26, 2016 at 11:01 PM, Bart Bogaerts <bartbogaerts@gmail.com> wrote:
> With a repo structured as follows
>
> main-files
> |- submod
>     |- subsubmodule
>
> git mv submod newlocation
>
> does not do what it is supposed to do. It actually breaks the git repository.
> It can be fixed easily.
> A complete description of the bug, including a workaround, can be found on
> http://stackoverflow.com/q/32782382/2274140

Which version of Git are you using?
I think this is fixed in a127331cd81233 (mv: allow moving nested
submodules, 2016-04-19), which is first included in v2.8.3
(or v2.9 and later).

Thanks,
Stefan

>
> --
> Bart Bogaerts
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

```

## Bart Bogaerts, 2016-06-27 20:07

Subject: Re: Git mv -- submodule -- recursive
Message-ID: <CAOG-3GJ5arRRixEAjMt00jp3A+ZQQ3bGXa+ZUQrpffJyAOP_4w@mail.gmail.com>
URL: https://gitlist.dev/e/CAOG-3GJ5arRRixEAjMt00jp3A%2BZQQ3bGXa%2BZUQrpffJyAOP_4w%40mail.gmail.com
In-Reply-To: <CAGZ79kYKBxL4xLyySALBv_-gqkss9_iCk-qSc4T7u7fKDMOFWw@mail.gmail.com>

```
Hi,

I tested this on git version 2.9 and it still fails (exactly the same
behaviour as on the stackoverflow post; also the workarounded I posted
there still works).
Some output showing the bug follows below:


bartb@EB-Latitude-E5450 ~/Documents/papers $ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
bartb@EB-Latitude-E5450 ~/Documents/papers $ git --version
git version 2.9.0
bartb@EB-Latitude-E5450 ~/Documents/papers $ git mv fo-c-revisited/ 2016
bartb@EB-Latitude-E5450 ~/Documents/papers $ git status
fatal: Not a git repository:
idp-latex/../../.git/modules/fo-c-revisited/modules/idp-latex
fatal: 'git status --porcelain' failed in submodule 2016/fo-c-revisited
bartb@EB-Latitude-E5450 ~/Documents/papers $ rm
2016/fo-c-revisited/idp-latex/.git
bartb@EB-Latitude-E5450 ~/Documents/papers $ git submodule update
bartb@EB-Latitude-E5450 ~/Documents/papers $ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

modified:   .gitmodules
renamed:    fo-c-revisited -> 2016/fo-c-revisited

bartb@EB-Latitude-E5450 ~/Documents/papers $

2016-06-27 19:57 GMT+03:00 Stefan Beller <sbeller@google.com>:
> On Sun, Jun 26, 2016 at 11:01 PM, Bart Bogaerts <bartbogaerts@gmail.com> wrote:
>> With a repo structured as follows
>>
>> main-files
>> |- submod
>>     |- subsubmodule
>>
>> git mv submod newlocation
>>
>> does not do what it is supposed to do. It actually breaks the git repository.
>> It can be fixed easily.
>> A complete description of the bug, including a workaround, can be found on
>> http://stackoverflow.com/q/32782382/2274140
>
> Which version of Git are you using?
> I think this is fixed in a127331cd81233 (mv: allow moving nested
> submodules, 2016-04-19), which is first included in v2.8.3
> (or v2.9 and later).
>
> Thanks,
> Stefan
>
>>
>> --
>> Bart Bogaerts
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Bart Bogaerts

```

## Stefan Beller, 2016-06-27 21:20

Subject: Re: Git mv -- submodule -- recursive
Message-ID: <CAGZ79kbdb39NAF4wC35aH6kY7QGTjqkg=Q1RWmOzcO_d9-ZMHA@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kbdb39NAF4wC35aH6kY7QGTjqkg%3DQ1RWmOzcO_d9-ZMHA%40mail.gmail.com
In-Reply-To: <CAOG-3GJ5arRRixEAjMt00jp3A+ZQQ3bGXa+ZUQrpffJyAOP_4w@mail.gmail.com>

```
On Mon, Jun 27, 2016 at 1:07 PM, Bart Bogaerts <bartbogaerts@gmail.com> wrote:
> Hi,
>
> I tested this on git version 2.9 and it still fails (exactly the same
> behaviour as on the stackoverflow post; also the workarounded I posted
> there still works).

I see. the commit I referenced was solving a slightly different problem, than
what we do here. That commit only fixed the issue for submodules in a nested
directory.

The important detail what is different in this case is having another
nested submodule.

If you only had

- git-repo a
-- subdirectory 2015
--- git-submodule b
-- git-submodule c

(quoted from SO)

then `git mv c 2015/` is expected to work as well as
`mkdir d && git mv 2015 d/` with submodule b being nested in 2015.

but as you have a submodule inside of c, moving c is buggy.

Stefan

```
