After I have moved a file in git (using git mv
), looking at the log for that file only shows the commits including and after the move.
Is there any way to view the commits applied to the file under its old name? In the example, below, I'd like to see commits b04033bdc44f1 and 8ca40d563ce5d in git log
after I've done the move.
$ git init
Initialized empty Git repository in /Users/ben/code/git_mv_example/.git/
$ touch foo
$ git add foo
$ git commit -m "Initial commit"
Created initial commit 8ca40d5: Initial commit
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 foo
[master*]$ echo "abcdefg" > foo
[master*]$ git commit -a -m "edited foo"
Created commit b04033b: edited foo
1 files changed, 1 insertions(+), 0 deletions(-)
$ git log foo
commit b04033bdc44f1eb3477270b4b7ca727377d8c03a
Author: Ben Brinckerhoff <[email protected]>
Date: Tue Jun 2 13:26:53 2009 -0600
edited foo
commit 8ca40d563ce5d07d965bfb75a01b9c23378fd321
Author: Ben Brinckerhoff <[email protected]>
Date: Tue Jun 2 13:26:15 2009 -0600
Initial commit
$ git mv foo bar
[master+]$ git commit -a -m "renamed foo to bar"
Created commit 2bccdf6: renamed foo to bar
1 files changed, 0 insertions(+), 0 deletions(-)
rename foo => bar (100%)
$ git log bar
commit 2bccdf6fc65b9da5b279d9f1117e436549dd3a7b
Author: Ben Brinckerhoff <[email protected]>
Date: Tue Jun 2 13:27:14 2009 -0600
renamed foo to bar
$ git log foo
fatal: ambiguous argument 'foo': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
Is this not possible? Or perhaps is git log
the wrong command for this?