Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show date and time of a commit by hash

Tags:

git

I used git reflog to identify a hash for when I created a particular branch. I got the hash of fe1ddcdef. I haven't pushed this branch to the remote yet. I'm now trying to find the date and time for when fe1ddcdef took place. git reflog only shows me:

fe1ddcdef HEAD@{11}: checkout: moving from master to handoff

which does not have a date or time.

git log is far too verbose, since it contains commits from all of my colleagues and I can't easily find the needle of fe1ddcdef in that haystack.

How can I simply find the date and time of commit fe1ddcdef?

like image 544
Mike Eng Avatar asked May 21 '18 16:05

Mike Eng


People also ask

How do I see the timestamp of a commit?

Hover over the 'xx days ago' label next to the relevant commit under the History tab, pause and wait for the Tooltip to appear.

How can I see commit date?

If you want to see commit date, you can use one of the many command line options, such as --pretty=fuller . Note the (slight) difference between the author date and commit date above.

Do git commits have timestamp?

There are actually two different timestamps recorded by Git for each commit: the author date and the commit date. When the commit is created both the timestamps are set to the current time of the machine where the commit was made.

How do I see commit hash?

If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .


1 Answers

Simply use :

git show fe1ddcdef 

… to display the content of the commit. Actually, once you have any expression that identifies a commit object, you can use it in all places that require a revision. These expressions can be an hexadecimal hash (even partial), a branch name or a tag name. It can also be one of these, associated to one or many operators such as "^", or "~", or "@".

This means that you can also use git log fe1ddcdef to get the full history of the branch starting from this point.

If you want to get only date and time of it and nothing else, you can type :

git show --no-patch --no-notes --pretty='%cd' fe1ddcdef 

Replace '%cd' by '%h %cd %s' to add hash summary and commit's subject message.

like image 99
Obsidian Avatar answered Sep 22 '22 15:09

Obsidian