How to output git log with the first line only? How to output git log with the first line only? git git

How to output git log with the first line only?


Have you tried this?

git log --oneline 

It's an alias for git log --pretty=oneline --abbrev-commit, and displays the "short sha" and "short description", for example:

9bee8857 Write more code831fdd6e Write some code Second line of message

The problem is that you are missing an empty line after the first line of your commit message. 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.


If you need no hashes and just the first lines, use %s for subject lines:

git log --pretty=format:%s

If you want the full commit message, use %B for subject and body:

git log --pretty=format:%B

There's also %b for just the body, along with many more options.