Bug with "git mv" and submodules, and with "git submodule add something --force"
- From
- Juergen Vogl <juergen.vogl@jku.at>
- Date
- Oct 19, 2018, 12:33 UTC
- Message-ID
- <c4792c95-9a19-fd0e-9171-fded095b78a6@jku.at>
Hi there,
tested on both, git 2.18 and git 2.19.1:
moving a file with `git mv` from a project to a submodule results in an **undefined state** of the local repository.
It breaks up the submodule (it's still in .gitmodules, but not accessable via `git submodule`), and is not reversible on local repository.
Either `git mv submodule/file .` nor deleting the folder works. For the locale repo the submodule is gone. But: trying to add it with `git submodule add` also do not work and results in an error message (with and without `--force` flag):
$ git submodule add git@github.com:-----------/wiki-public.git public --force A git directory for 'public' is found locally with remote(s): origin git@github.com:-----------/wiki-public.git If you want to reuse this local git directory instead of cloning again from git@github.com:-----------/wiki-public.git use the '--force' option. If the local git directory is not the correct repo or you are unsure what this means choose another name with the '--name' option.
Therefore, it's in a undefined, broken state.
Another bug I've got by testing upper line: * --force will be used as folder name * when used in `git submodule add git@github.com:someone/some.git --force`:
$ git submodule add git@github.com:---/wiki-public.git --force Cloning into '/home/---/---/---/---/wiki-internal.wiki/--force'... remote: Enumerating objects: 29, done. remote: Counting objects: 100% (29/29), done. remote: Compressing objects: 100% (25/25), done. remote: Total 29 (delta 5), reused 20 (delta 2), pack-reused 0 Receiving objects: 100% (29/29), 37.03 KiB | 421.00 KiB/s, done. Resolving deltas: 100% (5/5), done. /usr/libexec/git-core/git-submodule: line 273: cd: --: invalid option cd: usage: cd [-L|-P] [dir] Unable to checkout submodule '--force'
but it creates the `--force` folder:
$ tree . ├── --force
Best,
Jürgen Vogl