Hello:
I'm running into the problem described in this mailing list post: http://thread.gmane.org/gmane.comp.version-control.git/202645
'git subtree split' fails to reconstruct the history when a revert commit is followed by a merge commit. I have slightly adjusted the test script provided by Fabien in his mailing list post:
git init
# create a directory that is going to be split
mkdir doc
echo "TEST" > doc/README
git add doc
# commit A
git commit -a -m"first version"
# create a branch with a new commit (Z)
git checkout -b test
echo "TEST" > doc/README1
git add doc/README1
git commit -a -m"added README1"
git checkout master
# modify the README file (commit B)
echo "TEST_" > doc/README
git commit -a -m"second version"
# revert the change (commit C)
echo "TEST" > doc/README
git commit -a -m"revert second version"
# or use git revert HEAD^
# split
git subtree split --prefix="doc" --branch=TARGET
# add another commit (to a file *not* in the subtree dir)
echo "BLA" > BLA
git add BLA
git commit -a -m"third version"
# adding another commit to a file in the subtree dir will "fix" things
#echo "MEH" > doc/MEH
#git add doc
#git commit -a -m"fourth version" # the log will show the 3 commits as expected (including B and C)
GIT_PAGER= git log --oneline TARGET
# merge the test branch
git merge -m"merged test" test
# attempt to re-split; this will fail
git subtree split --prefix="doc" --branch=TARGET
# see what history split generates
git subtree split --prefix="doc" --branch=TARGET2I have discovered that if the revert commit is followed by another commit that makes changes in the subtree directory, the split will work as expected (see "fourth version" above).
See also this related SO question where I ask for a workaround: http://stackoverflow.com/questions/18465867
Best regards, Brecht