git log

git

書き方

git log [--oneline] [--graph] [<range>] [-- <path>]

コミット履歴を新しい順に見せますが、出るのは今のHEADの祖先だけで、他のブランチまで見るには--allが必要です。

よく使うオプション

オプション意味
--onelineone short line per commit
--graphdraw the branch lines
--allinclude every branch, not just the current one
-pshow the patch of each commit
--statshow which files changed
-n <n>stop after n commits
--since=<date>commits newer than a date, e.g. "2 weeks ago"
--followkeep following one file through renames

git log --oneline --graph --all

the whole history as a compact graph

git log -p -- src/app.ts

every change ever made to one file

git log --since="2 weeks ago" --author=jade

recent commits by one person

取り消しに何通りもあるのが混乱のもとです — ブランチの指す先を動かすのと、打ち消すコミットを積むのは別です。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. git log は何をしますか。

コミット履歴を新しい順に見せますが、出るのは今のHEADの祖先だけで、他のブランチまで見るには--allが必要です。

Q. どう打ちますか。

git log [--oneline] [--graph] [<range>] [-- <path>] — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは8個です。全部は man git にあります。このコマンドはgitの仲間です。

関連するコマンド

man ページ: man git-log