LoginSignup
1
0

More than 5 years have passed since last update.

[Git] 直前のコミットのコミッターの名前とメールアドレスを取得する

Posted at

CIで自動コミット処理をしたい場合に、直前のコミットの名前とメールアドレスを再利用したいケースがあったためやり方をメモ

対応方法

git log -1 --pretty=format:'XX' を利用すれば色々と情報を取得できる。

直前のコミットのコミッターの名前を取得
$ git log -1 --pretty=format:'%an'
Taro Tanaka
直前のコミットのコミッターのメールアドレスを取得
$ git log -1 --pretty=format:'%ae'
tanaka.taro@example.com

その他のフォーマット指定に関しては以下などを参照

Git - pretty-formats Documentation
git logのフォーマットを指定する - Qiita

参考

Script to get last commit author name in git - Stack Overflow

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0