Search code examples
gittortoisegitgit-subtree

Git subtree add does not show per-file history on added files... correct behaviour?


I've never used git subtree before, but am trying to migrate a git repository into my code repo as below:

C:\code>git subtree add -P database/scripts c:\git\other-repo HEAD -m="Migrate from other-repo"

I get no errors and I can see all the commits merging into my history, and I can see the diffs on merged historical commits but when I try to look at the log of an individual file that was merged in (in TortoiseGit) it only shows a single commit, rather than dozens in other-repo. The commit history of the file isn't shown even though I can see the commits and diffs are present in the repository history

I can't screenshot the commits but since I'm not using --squash I'm wondering if this is expected. Am I misunderstanding how subtree works?


Solution

  • During that merge commit, files also get "renamed" : a file that was located at that/file.sql in the original repo is now located at database/scripts/that/file.sql.

    Try running :

    git log --graph -- database/scripts/that/file.sql that/file.sql
    

    you should see commits that touch to both locations.


    git log also has a way to not handle merge commits by default ; the following combination of options seem to work on my machine :

    # '--cc' is one of the options that tell git log to inspect the content of merge commits
    git log --cc --follow --graph -- database/scripts/that/file.sql