git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Bug with "git mv" and submodules, and with "git submodule add something --force"

From
JVJuergen 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
Next: Stefan Beller
Message 1 of 6 in “Bug with "git mv" and submodules, and with "git submodule add something --force"”
  1. Juergen VoglOct 19, 2018
  2. Stefan BellerOct 19, 2018
  3. Jonathan NiederOct 19, 2018
  4. Junio C HamanoOct 22, 2018
  5. Stefan BellerOct 22, 2018
  6. Junio C HamanoOct 24, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.