git-subtree without squash: view log

后端 未结 2 1615
猫巷女王i
猫巷女王i 2020-12-15 22:26

I merged a tree onto a my repository by using git subtree add without the squash option. A git log shows that the commits were successfully added to the repository. Howev

2条回答
  •  悲哀的现实
    2020-12-15 22:43

    The commit created by git subtree merge or git subtree add does an "add" for the files coming from the subtree, not a "move". This means that their history cannot be tracked as with other merges or movements.

    History for the file you want can still be displayed by looking directly in the subtree before the merge. If your workspace is the merge commit that git subtree created then the second parent of it (HEAD^2) will be the last commit of the original subtree. From here you can see the contents of the original subtree:

    # Display the contents of the original subtree
    git ls-tree HEAD^2
    

    From this commit you can track the changes of the file you are interested. Be careful that the path of your file will be different within the subtree that in your workspace. You will need to remove the --prefix given to git subtree in order to have the correct path for your file.

    git log HEAD^2 --follow -- path-in-subtree/file
    

提交回复
热议问题