Display last git commit comment

前端 未结 10 643
南旧
南旧 2020-12-02 03:36

Often during a commit ($ git -commit -m \"\"), I wish to read my last comment to remember what progress I have made. Is there an easy way to directly access the

相关标签:
10条回答
  • 2020-12-02 04:28

    I did this

    git reflog -1 | sed 's/^.*: //'
    
    0 讨论(0)
  • 2020-12-02 04:28

    If you want to see just the subject (first line) of the commit message:

    git log -1 --format=%s
    

    This was not previously documented in any answer. Alternatively, the approach by nos also shows it.

    Reference:

    • git log - emsem
    0 讨论(0)
  • 2020-12-02 04:29

    To start with git log -1 --pretty='%s'

    But the below one covers all the cases,

    git log --pretty='format:%Creset%s' --no-merges -1

    • No unwanted white spaces
    • Discards merge commits
    • No commit id, date, Displays only the messages.

    Paste & see for yourself

    0 讨论(0)
  • 2020-12-02 04:30
    git show
    

    is the fastest to type, but shows you the diff as well.

    git log -1
    

    is fast and simple.

    git log -1 --pretty=%B
    

    if you need just the commit message and nothing else.

    0 讨论(0)
提交回复
热议问题