简体   繁体   中英

Viewing GIT history of moved files

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 here seems to only show history until the previous move. I understand that GIT doesn't track files, only their content. So surely I should be able to view the full evolution of a file, even if it's been moved?

Can anyone direct me to a good yet simple example/tutorial?

I'd like to see an example where some files are moved around, changed and committed, then the history of a single file is displayed, moves and all. I've been looking at 'log' but that seems to concern checkins. Would still appreciate some advice, even if its says I'm somehow still thinking too much SVN.

尝试使用--follow选项来git log

git log --follow file.txt

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM