ペペロンチーノ街道

無知を晒す

gitコマンドで最新のコミットのchanged filesを取得


背景

最新コミットでのchanged filesとなったファイル名をコマンドで取得したい!

結論

git log -m -1 --name-only --pretty=format:

メモ

  • -n ${num} で表示件数を制御 ここでは最新コミットでの変更を見たいので1
  • --name-only はファイル名を表示

    Show only names of changed files. The file names are often encoded in UTF-8. For more information see the discussion about encoding in the git-log[1] manual page.

  • --pretty=format: 表示形式を制御する

    • 例えば --pretty=format:"%s" とすればコミットメッセージを表示できる

参考

git-scm.com

git-scm.com