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

Possible bug with git subtree pull

From
DCDouglas J. Clutter <dougc@douglas-associates.com>
Date
Jun 7, 2019, 22:30 UTC
Message-ID
<DM5PR2201MB10819C1E74000E91B09F157982100@DM5PR2201MB1081.namprd22.prod.outlook.com>
It appears the git subtree pull command may have some problems.
The script below demonstrates the problem as follows:
1) Create a repo with a lib folder
2) Create another repo that uses the lib folder via git subtree push/add - the initial operation works as expected
3) Update the original lib folder as follows: modify an existing file and add a new file
4) Commit the changes reports "1 file changed, 1 insertion(+)"
5) Use git subtree push/pull - seems to work: returns message "1 file changed, 1 insertion(+)"
6) The new file is there, but the changed file is not updated
The expected behavior is:
	git subtree pull - would merge both the updated file and the new file
Actual behavior is:
	git subtree pull - adds the new file but does not merge changes to the existing file
Have confirmed behavior on both Windows and Ubuntu.
git --version is 2.17.1 in Ubuntu

Here is the full Ubuntu script: clear echo Test git subtree

export gitTestRoot="/home/dougc/git-test" export librepo="$gitTestRoot/librepo" export uselibrepo="$gitTestRoot/uselibrepo"

echo Clean-up cd / rm -rf $gitTestRoot

echo Initialize repos mkdir $gitTestRoot mkdir $librepo cd $librepo git init mkdir $uselibrepo cd $uselibrepo git init

echo Add files to librepo cd $librepo echo Hi >fileInRoot.txt mkdir lib cd lib echo Mom >fileInLib.txt cd .. git add fileInRoot.txt git add lib/fileInLib.txt git commit -m "Initial files in repo with lib"

echo Add files to uselibrepo cd $uselibrepo echo Excellent>file1.txt git add file1.txt git commit -m "Initial files in repo that will have lib subtree"

echo Add subtree to uselibrepo cd $librepo git subtree push --prefix=lib $uselibrepo libBranch cd $uselibrepo git subtree add --prefix=lib $uselibrepo libBranch git branch -D libBranch

echo Add/change files in lib cd $librepo/lib echo Dad >fileInLib.txt echo Adventure >anotherLib.txt git add anotherLib.txt git commit -m "Updates to lib in original location"

echo Share changes cd $librepo git subtree push --prefix=lib $uselibrepo libBranch cd $uselibrepo git subtree pull --prefix=lib -m "Merging" $uselibrepo libBranch git branch -D libBranch

echo New file is found in both places cat $librepo/lib/anotherLib.txt cat $uselibrepo/lib/anotherLib.txt

echo Changed file is NOT the same in both places cat $librepo/lib/fileInLib.txt cat $uselibrepo/lib/fileInLib.txt

Message 1 of 1 in “Possible bug with git subtree pull”
  1. Douglas J. ClutterJun 7, 2019

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.