0
0

More than 1 year has passed since last update.

How to find out deleted file's commit log?

Posted at

git logで–diff-filterと–summaryオプションを使用

$ git log --diff-filter=D --summary

commit 1826ae41824b57d60b2968917a43323e13d13c36
Author: foobar test@example.com
Date: Mon Apr 29 01:09:24 2019 +0900

コミットメッセージ

delete mode 100644 foo/bar.txt

表示量が多い場合は、スクロールして表示していくことになります。

デフォルトのエディタを使用しているならviの操作になっていると思うので、その場合は「/」を押して、更に削除したファイル名を入力して検索し、対象のコミットを見つけます。
オプションについて
–diff-filterオプション

次に示すのはgit logのマニュアルです。

--diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown (X), or

have had their pairing Broken (B). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if there is any file
that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.

Also, these upper-case letters can be downcased to exclude. E.g.
--diff-filter=ad excludes added and deleted paths.

Note that not all diffs can feature all types. For instance, diffs from the index to the working tree can never have Added entries (because the set of paths included in the diff is limited by what is in
the index). Similarly, copied and renamed entries cannot appear if detection for those types is disabled.

今回は削除したファイルを探すことが目的のため、D(Deleted)を使用しましたが、その他にA(Added)やM(Modified)などがあります。
–summaryオプション

summaryオプションの説明を下記に記載します。

このオプションを付けることで、ファイル名がgit logに表示されます。

--summary
Output a condensed summary of extended header information such as creations, renames and mode changes.
0
0
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
0
0