git subtree pull incorrectly reports merge conflict

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]