{"thread":{"id":"51263","subject":"Possible bug with git subtree pull","startedAt":"2019-06-07T22:30:13Z","lastAt":"2019-06-07T22:30:13Z","messageCount":1,"participants":["Douglas J. Clutter"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"376852","messageId":"DM5PR2201MB10819C1E74000E91B09F157982100@DM5PR2201MB1081.namprd22.prod.outlook.com","threadId":"51263","inReplyTo":null,"subject":"Possible bug with git subtree pull","fromName":"Douglas J. Clutter","fromEmail":"dougc@douglas-associates.com","sentAt":"2019-06-07T22:30:07Z","receivedAt":"2019-06-07T22:30:13Z","isPatch":false,"sender":{"key":"dougc@douglas-associates.com","avatar":null},"body":"It appears the git subtree pull command may have some problems.\n\nThe script below demonstrates the problem as follows:\n1) Create a repo with a lib folder\n2) Create another repo that uses the lib folder via git subtree push/add - the initial operation works as expected\n3) Update the original lib folder as follows: modify an existing file and add a new file\n4) Commit the changes reports \"1 file changed, 1 insertion(+)\"\n5) Use git subtree push/pull - seems to work: returns message \"1 file changed, 1 insertion(+)\"\n6) The new file is there, but the changed file is not updated\n\nThe expected behavior is:\n\tgit subtree pull - would merge both the updated file and the new file\n\nActual behavior is:\n\tgit subtree pull - adds the new file but does not merge changes to the existing file\n\nHave confirmed behavior on both Windows and Ubuntu.\n\ngit --version is 2.17.1 in Ubuntu\n\nHere is the full Ubuntu script:\nclear\necho Test git subtree\n\nexport gitTestRoot=\"/home/dougc/git-test\"\nexport librepo=\"$gitTestRoot/librepo\"\nexport uselibrepo=\"$gitTestRoot/uselibrepo\"\n\necho Clean-up\ncd /\nrm -rf $gitTestRoot\n\necho Initialize repos\nmkdir $gitTestRoot\nmkdir $librepo\ncd $librepo\ngit init\nmkdir $uselibrepo\ncd $uselibrepo\ngit init\n\necho Add files to librepo\ncd $librepo\necho Hi >fileInRoot.txt\nmkdir lib\ncd lib\necho Mom >fileInLib.txt\ncd ..\ngit add fileInRoot.txt\ngit add lib/fileInLib.txt\ngit commit -m \"Initial files in repo with lib\"\n\necho Add files to uselibrepo\ncd $uselibrepo\necho Excellent>file1.txt\ngit add file1.txt\ngit commit -m \"Initial files in repo that will have lib subtree\"\n\necho Add subtree to uselibrepo\ncd $librepo\ngit subtree push --prefix=lib $uselibrepo libBranch\ncd $uselibrepo\ngit subtree add --prefix=lib $uselibrepo libBranch\ngit branch -D libBranch\n\necho Add/change files in lib\ncd $librepo/lib\necho Dad >fileInLib.txt\necho Adventure >anotherLib.txt\ngit add anotherLib.txt\ngit commit -m \"Updates to lib in original location\"\n\necho Share changes\ncd $librepo\ngit subtree push --prefix=lib $uselibrepo libBranch\ncd $uselibrepo\ngit subtree pull --prefix=lib -m \"Merging\" $uselibrepo libBranch\ngit branch -D libBranch\n\necho New file is found in both places\ncat $librepo/lib/anotherLib.txt\ncat $uselibrepo/lib/anotherLib.txt\n\necho Changed file is NOT the same in both places\ncat $librepo/lib/fileInLib.txt\ncat $uselibrepo/lib/fileInLib.txt\n\n"}]}