Search code examples
gitmergegit-subtree

git diff-tree showing changedset already merged


Just starting out with git subtree's. I've followed the official beginners tutorial.

In my working copy in directory A of repository A, I've added a subtree at subdirectory B for the repository B. The branch name I've used for checking out B's master is also B.

I've made a commit in branch B and checked out A's master, git diff-tree -p B has presented a diff corresponding to the last commit in B.

I've then applied the following command:

git merge --squash -s subtree --no-commit B

And commited.

I've checked the merge went well, but the same diff-tree command from before is still presenting the same diff corresponding to the last commit in B, even though checking through git log and normal git diff I can see the commit was applied to master, I dunno why the previous diff-tree is persisting.

Why and what I'm doing wrong?


Solution

  • The issue seems to be that according to the diff-tree help it doesn't 'do' what that example purports it to be doing. If you only supply one treeish in this case B then it compares the tree-ish with its parent.. That parent doesn't change regardless of how many times you merge it in. I think some of this has been obscured because in both your example and theirs the same branch name for both their folder and the branch is used.

    If you instead say:
    git diff-tree -p HEAD:B B or git diff-tree -p HEAD:B B/B it should show you that there is no difference between those two trees.