git log
git
書き方
git log [--oneline] [--graph] [<range>] [-- <path>]コミット履歴を新しい順に見せますが、出るのは今のHEADの祖先だけで、他のブランチまで見るには--allが必要です。
よく使うオプション
| オプション | 意味 |
|---|---|
| --oneline | one short line per commit |
| --graph | draw the branch lines |
| --all | include every branch, not just the current one |
| -p | show the patch of each commit |
| --stat | show which files changed |
| -n <n> | stop after n commits |
| --since=<date> | commits newer than a date, e.g. "2 weeks ago" |
| --follow | keep following one file through renames |
例
git log --oneline --graph --allthe whole history as a compact graph
git log -p -- src/app.tsevery change ever made to one file
git log --since="2 weeks ago" --author=jaderecent 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