How to output git log with the first line only?

前端 未结 9 1830
猫巷女王i
猫巷女王i 2021-01-29 17:29

I am trying to customize the format for git log. I want all commits to be shown in one line. Each line should only show the first line of the commit message.
I

相关标签:
9条回答
  • 2021-01-29 18:13

    Have you tried this?

    git log --pretty=oneline --abbrev-commit
    

    The problem is probably that you are missing an empty line after the first line. The command above usually works for me, but I just tested on a commit without empty second line. I got the same result as you: the whole message on one line.

    Empty second line is a standard in git commit messages. The behaviour you see was probably implemented on purpose.

    The first line of a commit message is meant to be a short description. If you cannot make it in a single line you can use several, but git considers everything before the first empty line to be the "short description". oneline prints the whole short description, so all your 3 rows.

    0 讨论(0)
  • 2021-01-29 18:13

    Does git log --oneline do what you want?

    0 讨论(0)
  • 2021-01-29 18:17

    git log --format="%H" -n 1

    Use the above command to get the commitid, hope this helps.

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