Hi,

Today I realized that when you add a subtree with `git subtree add`,
then remove it with `git rm -r`, then re-add it again, pushing to the
subtree behaves weirdly: it adds the whole history of the main
repository to the sub repository.

Below is a list of commands to reproduce the issue:

```
mkdir myproj
mkdir mylib

cd mylib
touch mylib-file1
git init
git add mylib-file1
git commit -m "mylib initial commit"

cd ../myproj
touch myproj-file1
git init
git add myproj-file1
git commit -m "myproj initial commit"
git subtree add --squash -P contrib/mylib -m "added lib" ../mylib master
git rm -r contrib/mylib
git commit -m "removed lib"
git subtree add --squash -P contrib/mylib -m "re-adding lib" ../mylib master

git subtree push -P contrib/mylib ../mylib test

cd ../mylib
git checkout test
git log | cat
# expected: only "mylib initial commit"
# actual: full history of myproj
```

If you replace the last two occurrences of contrib/mylib by a
different folder such as contrib2/mylib, the push works as usual. I
suspect that subtree splits using the first commit in the subfolder in
the whole history, rather than the first commit after the folder was
last added.

Best regards,
Christian Zommerfelds
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to