[git] How to show first commit by 'git log'?

I have a project which has long history. I want to show the first commit on git.

How do I do this?

This question is related to git

The answer is


Not the most beautiful way of doing it I guess:

git log --pretty=oneline | wc -l

This gives you a number then

git log HEAD~<The number minus one>

git log --format="%h" | tail -1 gives you the commit hash (ie 0dd89fb), which you can feed into other commands, by doing something like

git diff `git log --format="%h" --after="1 day"| tail -1`..HEAD to view all the commits in the last day.


git log $(git log --pretty=format:%H|tail -1)

I found that:

git log --reverse

shows commits from start.


You can just reverse your log and just head it for the first result.

git log --pretty=oneline --reverse | head -1