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

git subtree pull incorrectly reports merge conflict

From
ELEric Lindsey <elindsey@ucsd.edu>
Date
Jun 22, 2013, 23:59 UTC
Message-ID
<CANFFsAZ-Q--3Kx_rYgkALd=nvo6r24sNpNQeHQdALYHhDwBxPQ@mail.gmail.com>

I'm having trouble pulling changes from a repo that was imported as a subtree with 'git subtree add'. The issue occurs when I have previously used 'git subtree push' from within the project directory, then pushed changes to the remote repo again from somewhere else (from another project also using it as a subtree, or directly with 'git push' -- doesn't matter). When I go back to the initial project, 'git subtree pull' has a merge conflict, and fails to merge the new changes. The reported conflict is half-empty, so I can't see why there is any conflict at all.

I've found an odd workaround, where calling "subtree pull" immediately after the "subtree push" from the project directory seems to keep things in sync and prevent the later conflict (see the script below). I'm stumped as to why running a pull should find any changes right after a push, but this is what happens. So it seems like a bug, unless I'm missing a critical step somewhere -- I'm fairly new to git still.

I've pasted a script below that reproduces the problem in a simple case, for my version of git (1.8.3.1, installed via homebrew on OS X 10.8.4).

Thanks, Eric

#start from scratch rm -rf foo bar foo.git

# create remote repo. for foo (bare) mkdir foo.git cd foo.git git init --bare cd ..

#create library foo and push to remote repo mkdir foo cd foo echo "this is a test file" > test.foo git init git add . git commit -m "initial commit to foo" git remote add origin ../foo.git git push origin master cd ..

#create a project that uses foo as subtree mkdir bar cd bar git init echo "test" > test.bar git add . git commit -m "initial commit to bar" git subtree add --prefix=foo ../foo.git master echo "modify foo from bar" >> foo/test.foo git add foo/test.foo git commit -m "update foo from bar" git subtree push --prefix=foo ../foo.git master ### if I uncomment the next line, final 'subtree pull' doesn't fail... why? #git subtree pull --prefix=foo ../foo.git master -m "pull right after push" cd ..

#now update foo from elsewhere cd foo git pull origin master echo "modify foo from foo" >> test.foo git add test.foo git commit -m "update foo again" git push origin master cd ..

# try to pull update from project bar cd bar git subtree pull --prefix=foo ../foo.git master -m "pull foo"

#above command fails to merge, and the reported conflict is half-empty. #resulting contents of bar/foo/test.foo are:

#this is a test file #modify foo from bar #<<<<<<< HEAD #======= #modify foo from foo #>>>>>>> f0a24eeb1614228a1368ae23112ff4923dcf557e

Message 1 of 1 in “git subtree pull incorrectly reports merge conflict”
  1. Eric LindseyJun 22, 2013

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.