git log コマンド
参考:
目次
使い方
参考:
git log コマンドでコミット履歴のリスト化 – Qiita
コミット履歴の閲覧 | Pro Git book [Official]
オプション
参考:
git log のオプションあれこれ | 煙と消えるその前に
条件指定してコミットを絞り込む | Yanor.net/Wiki
特定のユーザ (author, committer) のコミットログのみ表示 | dackdive’s blog
指定した件数だけ表示する
-n
オプションに続いて最大表示件数を指定する。
$ git log -n 10
最新の1件だけ表示する。
$ git log -1
参考:
-n | Git Documentation [Official]
一行表示
コミットをそれぞれ一行ずつで表示する。
$ git log --oneline
参考:
--oneline | Git Documentation [Official]
フォーマット
--pretty=format:"%h"
:ハッシュのみ表示する
--pretty=format:"%ad %C(yellow)%h%C(reset)%C(auto)%d%C(reset) %s"
:日付ありで一行表示する
参考:
git log のエイリアスを設定 | 別館 子子子子子子 はてブロ部
Git でコミットログの出力形式をカスタマイズする (git log --pretty, --date) | まくまくノート
美しき git log --graph のエイリアス | Hack Your Design!
pretty-formats | Git [Official]
Git Logs with Color and Graphs | Sweetmeat
How to format git log to generate meaningful information | Red Panthers
Git log format string cheatsheet | Devhints
Git pretty format colors – Stack Overflow
How to emulate git log --decorate’s different colors per branch-type – Stack Overflow
Color in git-log – Stack Overflow
How to configure ‘git log’ to show ‘commit date’ – Stack Overflow
ツリー構造を表示する
参考:
美しき git log --graph のエイリアス | Hack Your Design!
git graph を使ってターミナルで Git のツリー構造を表示する | ピクセルデザイン
日時のフォーマットを指定する
参考:
任意の日付フォーマットで git log を表示する – Qiita
git log の oneline オプションだと commit 日が表示されないのよね | IwazerReport
author date と commiter date そして GitHub | shigemk2
ログの日付を yyyy/MM/dd HH:mm:ss 形式にしたい – teratail
--date=<format> – git-log | Git [Official]
How to change Git log date formats – Stack Overflow
日時の範囲を指定する
参考:
git log で特定の期間のログだけを出力する方法 | gotohayato
指定日からの作業内容をテキストファイルに出力したい | かもメモ
How to get git to show commits in a specified date range for author date? – Stack Overflow
get commits since a particular date in git based on commit date – Stack Overflow
How does git log --since count? – Stack Overflow
git log の活用
-p
オプション:diff
を表示する- パスの指定:
git log -- **/*.rb
git log --word-diff
:字句単位のdiff
参考:
git log でファイルの変更履歴を確認/問題のコミットを特定! | WWW クリエイターズ
--name-only / --name-status
参考:
変更のあったファイル名を列挙する/内容の差分は表示しない – Qiita
git で、削除/追加/変更されたファイル一覧を取得するには? – スタック・オーバーフロー
--stat
参考:
Git で commit 間の変更ファイル一覧を出力 – Qiita
--diff-filter
参考:
削除されたファイルを git のコミット履歴から楽に探す便利コマンド | SUKEMATSU.NET
git diff のとき変更したファイルだけを確認する – Qiita
ソート順を指定する
参考:
git log を時間順にソートする | DQNEO 起業日記
Commit Ordering – git-log | Git [Official]
Can you order git log by commit timestamp? – Stack Overflow
How can I make git log order based on author’s timestamp? – Stack Overflow
--reverse
参考:
How do I find the next commit in git? (child/children of ref) – Stack Overflow
コミットメッセージを grep する
--grep
オプションを使う。
$ git log -i --oneline --grep sprockets
参考:
コミットメッセージで git log を検索する – Qiita
git log でコミットメッセージを検索する方法/コミットログでフィルタリング | DQNEO 起業日記
How to effectively search the Git log | Aurelien Navarre
Search git logs (case-insensitive) | commandlinefu.com
git grep コマンド
Git 管理されているファイルを grep
する。
$ git grep -i sprockets
参考:
git で文字列検索、git grep と git log -S がとっても便利 – Qiita
Git でソースコードのコミット履歴を検索する方法 – スタック・オーバーフロー
How to grep (search) committed code in the git history? – Stack Overflow
ファイルの差分が生じたコミットを検索する
-S
オプションを指定すると、指定した文字列の出現回数に変更があったコミット (各ファイルにおいて追加・削除が相殺しないコミット) を探す。
$ git --no-pager log --oneline -i -S sprockets
-S
オプション使用時に --pickaxe-regex
オプションを付けると、正規表現として探索する。
$ git --no-pager log --oneline --pickaxe-regex -i -S 'webpack(er)?'
-G
オプションを指定すると、差分の各行を正規表現で探索してヒットしたコミットを表示する。
$ git --no-pager log --oneline -i -G 'webpack(er)?'
-i
:パターンあるいは正規表現による探索で大文字小文字を区別しない
参考:
git で文字列検索、git grep と git log -S がとっても便利 – Qiita
git log でコミットの差分の中身で絞り込む – Qiita
git のログから特定の文字列を含むコミットを採掘する | Hack Your Design!
-S<string> – git-log | Git [Official]
--pickaxe-regex – git-log | Git [Official]
-G<regex> – git-log | Git [Official]
How to effectively search the Git log | Aurelien Navarre
削除したファイルの履歴を探す
--diff-filter=D
オプションを付けて git log
コマンドを実行する。
$ git log --diff-filter=D --oneline -- path/to/file
参考:
Git で過去に削除したファイルを検索、復元させる方法 | rcmdnk’s blog
削除済みのファイルを履歴から見つける方法 | Public Constructor
削除されたファイルを Git のコミット履歴から楽に探す便利コマンド | SUKEMATSU.NET
削除したファイルの削除 commit まで探索する git log のオプションがあった | F.Shibusawa
Git で特定のファイルをいつ削除したのか見つけ出す | えんぺる
Git でファイルがいつ削除されたかを特定する | PIYO
How to Find a Deleted File in the Project Commit History in Git | W3docs
How can I list all the deleted files in a Git repository? – Stack Overflow
How to find a deleted file in the project commit history? – Stack Overflow
-p / -u / --patch オプション
履歴と共に diff
を表示する。
参考:
Ignore case differences with git log – Stack Overflow
まとめ
参考:
git-log-times
git log
にコミット日を差し込む。
参考:
git-log-times a log --oneline alternative with dates, times and initials – GitHub Gist