Viewing GIT history of moved files

前端 未结 2 1340
孤城傲影
孤城傲影 2020-12-13 22:59

Despite reading lots of other posts regarding GIT and moved files I still struggle to understand how to trace the full history. Doing gitk myfile as suggested

相关标签:
2条回答
  • 2020-12-13 23:24

    Use git log with both --follow and --patch which will display the log with the rename from / rename to output. And don't forget the -- before the file path.

    git log --follow --patch -- path/to/file.ext
    

    For example the history of file testdir/more-testing.txt on my system shows:

    Date:   Wed Mar 18 14:48:07 2020 -0700
    
       renamed file
    
    diff --git a/testdir/testing.txt b/testdir/more-testing.txt
    similarity index 100%
    rename from testdir/testing.txt
    rename to testdir/more-testing.txt
    
    commit feb58d3ab8e8ce940f80499df0c46e8fc8caf679
    Author: Igal <redacted>
    Date:   Wed Mar 18 14:47:18 2020 -0700
    
       moved test.txt to subdirectory and renamed
    
    diff --git a/test.txt b/testdir/testing.txt
    similarity index 100%
    rename from test.txt
    rename to testdir/testing.txt
    
    commit 34c4a7cebaeb0df5afb950972d69adea6b1a7560
    Author: Igal <redacted>
    Date:   Wed Mar 18 14:45:58 2020 -0700
    
       added test.txt
    
    diff --git a/test.txt b/test.txt
    new file mode 100644
    index 000000000..0527e6bd2
    --- /dev/null
    +++ b/test.txt
    @@ -0,0 +1 @@
    +This is a test
    (END)
    
    
    0 讨论(0)
  • 2020-12-13 23:47

    Try using the --follow option to git log:

    git log --follow file.txt
    
    0 讨论(0)
提交回复
热议问题