git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Problem Following file history through sub-tree import

From
CACrabtree, Andrew <andrew.crabtree@hpe.com>
Date
Jun 22, 2016, 16:43 UTC
Message-ID
<CS1PR84MB0133D7DE01AB62F197ECED4CF92C0@CS1PR84MB0133.NAMPRD84.PROD.OUTLOOK.COM>

Having difficulty understanding how to invoke 'git log' to track the history of a file that was imported into a different location through a subtree merge. I had thought just '--follow' was needed, but I don't seem to be getting any results with that.

Example below.

Thanks! ~Andrew

git --version
   git version 2.9.0
cd /tmp
mkdir subtree_test
cd subtree_test
git init 
touch foo
git add foo
git commit -m "initial"
git remote add git_src https://github.com/git/git
git fetch git_src
git merge --allow-unrelated-histories -s ours --no-commit git_src/master 
git read-tree --prefix=git_src -u git_src/master
git commit -m "import git as subtree"
cd git_src
git log pager.c
commit 22e7b2600b54f25314c399d45b1ea45d2427c754
Merge: 8df5087 ab7797d
Author: Andrew Crabtree <andrew.crabtree@hpe.com>
Date:   Wed Jun 22 08:58:04 2016 -0700
    import git as subtree
git log --follow pager.c
# nothing 

gitk pager.c * # only shows merge commit 22e7b

git gui blame pager.c & # shows history as expected

git log HEAD^2 -- pager.c 
commit c3b1e8d85133e2a19d372b7c166d5b49fcbbfef2
Merge: 595bfef 708b8cc
Author: Junio C Hamano <gitster@pobox.com>
Date:   Wed Feb 24 13:26:01 2016 -0800
    Merge branch 'jc/am-i-v-fix'
    
    The "v(iew)" subcommand of the interactive "git am -i" command was
    broken in 2.6.0 timeframe when the command was rewritten in C.
    
    * jc/am-i-v-fix:
      am -i: fix "v"iew
      pager: factor out a helper to prepare a child process to run the pager
      pager: lose a separate argv[]
commit 3e3a4a41b0dac564c0302ced4ccc423d0d39bc21
Author: Junio C Hamano <gitster@pobox.com>
Date:   Tue Feb 16 14:34:44 2016 -0800
Message 1 of 1 in “Problem Following file history through sub-tree import”
  1. Crabtree, AndrewJun 22, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.