12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Git リポジトリ内で cp(1) でコピーしたファイルに対して、コピー前の変更履歴を見る

Posted at

git log --follow オプションで、コピー前にファイルのコンテンツがどのように変更されたかの履歴が見える。

$ git add 1.txt; git commit (a)
$ edit 1.txt; git add 1.txt; git commit (b)
$ cp 1.txt 2.txt
$ git add 2.txt; git commit (c)
$ edit 2.txt; git add 2.txt; (d)
$ git log 2.txt (c 移行の履歴しか見えない)
$ git log --follow 2.txt (a, b の履歴も見える)

参考 URL

--follow
Continue listing the history of a file beyond renames (works only for a single file).

12
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?