Gitの小ネタおれおれAdvent Calendar 2022 – 17 日目

git log --pretty=xxx で表示する内容をカスタマイズできます。

--pretty

以下の値を設定できるそうです。

  • oneline
  • short
  • medium
  • full
  • fuller
  • reference
  • email
  • mboxrd
  • raw
  • format:<format-string>

format: は任意の書式を指定できます。

それ以外をいくつか例示します。(ヘルプには全部載ってるよ。)

なし

これが基本形。

$ git log
commit 7f3301d361f4805c404603dd4d76fcfd36347419 (HEAD -> main)
Author: Joyce Er <[email protected]>
Date:   Wed Nov 30 22:19:51 2022 -0800

    Report cancellation errors in telemetry (#167799)

commit f3996b416f847af62eef1a50c6c678dedd47a92e
Author: Joyce Er <[email protected]>
Date:   Wed Nov 30 22:00:43 2022 -0800

    Add 1-step Continue in Local Folder option (#167795)

oneline

$ git log --pretty=oneline 
7f3301d361f4805c404603dd4d76fcfd36347419 (HEAD -> main) Report cancellation errors in telemetry (#167799)
f3996b416f847af62eef1a50c6c678dedd47a92e Add 1-step Continue in Local Folder option (#167795)
c87fa19f7932cefa1abeac4dd85ade3983780e14 cli: avoid interactions when running integrated (#167780)
968026a46db6ad769e0d9f3a048d2c7d780de083 Use includes instead of indexOf (#167778)
2a16bdb4677649893126816d2e22fce76288eeb7 Instrument webview usage (#167762)
56d73a45e38259976188a982331c9fb5d156cd25 Do not auto run source action when there is pending kernel detection. (#167763)
bffd0181d3f1b7978585f68c32e04ab3bf9094c0 Restrict hover focus trap behaviour to Settings indicators (#167756)
c8dd73b410cf379b0674959155c5928bf35336d4 Fix #167683. Show selected kernel name during kernel detectio

short

$ git log --pretty=short
commit 7f3301d361f4805c404603dd4d76fcfd36347419 (HEAD -> main)
Author: Joyce Er <[email protected]>

    Report cancellation errors in telemetry (#167799)

commit f3996b416f847af62eef1a50c6c678dedd47a92e
Author: Joyce Er <[email protected]>

    Add 1-step Continue in Local Folder option (#167795)

commit c87fa19f7932cefa1abeac4dd85ade3983780e14

medium

$ git log --pretty=medium
commit 7f3301d361f4805c404603dd4d76fcfd36347419 (HEAD -> main)
Author: Joyce Er <[email protected]>
Date:   Wed Nov 30 22:19:51 2022 -0800

    Report cancellation errors in telemetry (#167799)

commit f3996b416f847af62eef1a50c6c678dedd47a92e
Author: Joyce Er <[email protected]>
Date:   Wed Nov 30 22:00:43 2022 -0800

    Add 1-step Continue in Local Folder option (#167795)

full

$ git log --pretty=full
commit 7f3301d361f4805c404603dd4d76fcfd36347419 (HEAD -> main)
Author: Joyce Er <[email protected]>
Commit: GitHub <[email protected]>

    Report cancellation errors in telemetry (#167799)

commit f3996b416f847af62eef1a50c6c678dedd47a92e
Author: Joyce Er <[email protected]>
Commit: GitHub <[email protected]>

    Add 1-step Continue in Local Folder option (#167795)

fuller

$ git log --pretty=fuller
commit 7f3301d361f4805c404603dd4d76fcfd36347419 (HEAD -> main)
Author:     Joyce Er <[email protected]>
AuthorDate: Wed Nov 30 22:19:51 2022 -0800
Commit:     GitHub <[email protected]>
CommitDate: Thu Dec 1 07:19:51 2022 +0100

    Report cancellation errors in telemetry (#167799)

commit f3996b416f847af62eef1a50c6c678dedd47a92e
Author:     Joyce Er <[email protected]>
AuthorDate: Wed Nov 30 22:00:43 2022 -0800

reference

$ git log --pretty=reference
7f3301d361f (Report cancellation errors in telemetry (#167799), 2022-11-30)
f3996b416f8 (Add 1-step Continue in Local Folder option (#167795), 2022-11-30)
c87fa19f793 (cli: avoid interactions when running integrated (#167780), 2022-11-30)
968026a46db (Use includes instead of indexOf (#167778), 2022-11-30)
2a16bdb4677 (Instrument webview usage (#167762), 2022-11-30)
56d73a45e38 (Do not auto run source action when there is pending kernel detection. (#167763), 2022-11-30)
bffd0181d3f (Restrict hover focus trap behaviour to Settings indicators (#167756), 2022-11-30)
c8dd73b410c (Fix #167683. Show selected kernel name during kernel detection. (#167761), 2022-11-30)
cec4114c0c1 (Ignore position parameter for now when laying out notebook widget (#167759), 2022-11-30)
e84133953f2 (Add application.experimental.* to Settings UI (#167746), 2022-11-30)

email

$ git log --pretty=email
From 7f3301d361f4805c404603dd4d76fcfd36347419 Mon Sep 17 00:00:00 2001
From: Joyce Er <[email protected]>
Date: Wed, 30 Nov 2022 22:19:51 -0800
Subject: [PATCH] Report cancellation errors in telemetry (#167799)


From f3996b416f847af62eef1a50c6c678dedd47a92e Mon Sep 17 00:00:00 2001
From: Joyce Er <[email protected]>
Date: Wed, 30 Nov 2022 22:00:43 -0800
Subject: [PATCH] Add 1-step Continue in Local Folder option (#167795)

おしまい

いろいろあるもんですね。

format: の話をするつもりだったけどなんかいったんここで切ります。

参考