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

Submodule update setting not respected by git pull

From
James Limbouris <james@digitalmatter.com>
Date
Jun 3, 2021, 06:33 UTC
Message-ID
<SL2PR03MB39644447B726A8C024259AA2A43C9@SL2PR03MB3964.apcprd03.prod.outlook.com>
Hi Git community,
I've been wanting to use the git submodules feature for many years, but have always been put off by the ease with which you could lose work in the past. Much progress has now been made, and with the '[submodule] recurse = true' setting and the 'update = merge' setting, it's starting to look much safer.
The only remaining sharp edge seems to be the 'git pull' command. It doesn't seem to respect the 'update = merge' setting, and will overwrite a submodule version in your working copy with the submodule version from your remote, instead of merging or rebasing. I'm not sure if this is by design, or it's a bug? But it seems like a bug, since 'git pull' is respectful of uncommitted changes in the submodule, and also won't overwrite the submodule version if it has been staged in the containing project.

Git version: 2.31.1.windows.1 Steps to reproduce:

1. Add a submodule to your project, with the 'update = merge' setting, and default recursion to on:
[submodule "modules/mylibrary"]
	active = true
	url = <. . .>
	update = merge
[submodule]
	recurse = true
2. Cd into the submodule, checkout master, and add a new commit
3. Cd back into the enclosing project
4. 'git submodule update --init --recursive --remote' will correctly leave your submodule pointing at the new commit
5. 'git pull --rebase' will correctly leave your submodule pointing at the new commit
6. But 'git pull' will replace your submodule with a detached head, ignoring the 'update = merge' setting
This will then lead to lost work when you fail to notice, and commit the reverted submodule version in the enclosing project.
Am I wrong to want 'git pull' to use the 'update = merge' setting - is this a feature?

Regards, James Limbouris

Message 1 of 1 in “Submodule update setting not respected by git pull”
  1. James LimbourisJun 3, 2021

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.