threads / bug / 51263

Possible bug with git subtree pull

Subject: Possible bug with git subtree pull

## tl;dr

One message between Jun 7, 2019 and Jun 7, 2019.

replies: 0people: 1as markdown or json

Douglas J. Clutter· Jun 7, 2019, 22:30 UTC · lore
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

← back to recent threads