0
1

git logコマンドで自分がこれまでにcommitした内容をすべて見る

Posted at

git repositoryの中で自分がこれまでに書いた差分を振り返ったり、自分が書いた範囲だけで検索したいときなどに使うワンライナーです。

git log --pretty=format:"%an %h" | grep suzuki | perl -nle 'print "git show $1" if /\b([a-f0-9]{9})\b/' | bash | less

grep のところで自分のcommitしているときの名前を入れます。

端末上でカラフルに表示したい場合は

git log --pretty=format:"%an %h" | grep suzuki | perl -nle 'print "git show --color=always $1" if /\b([a-f0-9]{9})\b/' | bash | less -R

こんな感じで見れるはずです。

commit a2c89149042310b34583cfbaf7b2b98ca5b8fea4
Author: suzuki
Date:   Fri Jul 26 12:12:49 2024 +0900

    commitコメントコメントコメント...

diff --git a/src/hello.py b/src/hello.py
index b06e8ccb4..cabe8a15d 100644
--- a/src/hello.py
+++ b/src/hello.py
@@ -112,7 +112,7 @@ def hello(
     ...
     ...
     ...
-    aaa
+    bbb
     ...
     ...
     ...

commit a571ee8f8cf0eec4bc7f57f35f151ca9fbb7598b
...

lessコマンドの中で検索できますので、過去に自分が書いたはずの部分がどこだったか忘れたときにこれで検索できます。

0
1
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
0
1