Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See "real" commit date / time in github (hour/day)

Is there a way to see the date of a commit in github, with day/hour precision? Older commits appear in a "human readable" format, such as "2 years ago" instead of showing the actual date.

old github commit

If it's not possible to see the actual date on github, is there a easier workaround than git clone?

like image 899
loopbackbee Avatar asked Dec 10 '13 16:12

loopbackbee


People also ask

Can you see the exact time of a commit on github?

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

Does git commit record time?

git does not log when things are pushed into a repository (or fetched for that matter), only the two timestamps on the commits themselves, so I don't think there's a reliable way to do this without writing hooks that would store extra metadata somewhere for you, or relying on logging done by git-daemon, ssh, or your ...

Can you change Github commit time?

Just do git commit --amend --reset-author --no-edit . For older commits, you can do an interactive rebase and choose edit for the commit whose date you want to modify.


7 Answers

Hover your mouse over the 2 years ago and you'll get the timestamp.

like image 199
Matt S. Avatar answered Oct 02 '22 15:10

Matt S.


The real date does not appear for me upon hovering "2 years ago", despite the text being wrapped by a <time> element with an iso value under its datetime attribute.

If all else fails, like it did for me, try inspecting the text.

Sample element:

<time datetime="2015-01-22T20:48:13Z" is="relative-time" title="Jan 22, 2015, 2:48 PM CST">7 days ago</time>

like image 31
Walter Roman Avatar answered Oct 02 '22 15:10

Walter Roman


I tried @odony's TamperMonkey/Greasemonkey script on Chrome but couldn't get it to work. detachCallback() wasn't recognized. So instead of detaching any callbacks, I simply replaced the <relative-time> node.

// ==UserScript==
// @name         Github: always show absolute times
// @match        https://github.com/*
// ==/UserScript==

(function() {
    document.querySelectorAll("relative-time").forEach(function(el) {
        var parent = el.parentNode;
        var timestamp = el.title;
        var span = document.createElement("span");
        span.innerHTML = timestamp;
        parent.removeChild(el);
        parent.appendChild(span);
    });
})();

Sorry I haven't tested this with other browser, but since this is basic javascript, it should just work. :)

like image 21
Mr. T Avatar answered Oct 02 '22 15:10

Mr. T


you can just use this js bookmark:

javascript:(function() { 
        var relativeTimeElements = window.document.querySelectorAll("relative time");
        relativeTimeElements.forEach(function(timeElement){
        timeElement.innerHTML = timeElement.innerHTML +" -- "+ timeElement.title;
        })
    }()
)

https://gist.github.com/PhilippGrulich/7051832b344d4cbd30fbfd68524baa38

It adds just the correct time: Like this: committed 21 hours ago -- 15. Feb. 2017, 15:49 MEZ

like image 30
Philipp Grulich Avatar answered Oct 02 '22 14:10

Philipp Grulich


If you're looking for a way to display the date/time permanently without hovering (e.g. for screenshots), the above Javascript-based solutions do not match the latest Github HTML (see comments). And they did not take into account the fact that the timestamps are auto-updated based on a timer ("X minutes ago" has to change every minute), so they will periodically reappear.

The following script seems to work on Github as of 2020-01-27:

(function() {
    var els = window.document.querySelectorAll("time-ago,relative-time");
    els.forEach(function(el) {
        el.innerHTML = "on " + el.getFormattedTitle(); // original timestamp
        el.disconnectedCallback(); // stop auto-updates
    });
})();

You can make this a bookmarklet by prefixing the code with javascript: as in the other JS-based solution.

And if you want to make this a permanent fix, you can save this as a TamperMonkey/Greasemonkey script, as follows:

// ==UserScript==
// @name         Github: always show absolute times
// @match        https://github.com/*
// ==/UserScript==

(function() {
    setTimeout(function() {
        var els = window.document.querySelectorAll("time-ago,relative-time");
        els.forEach(function(el) {
            el.innerHTML += ' <span class="text-small">(' + el.title + ')</span>'; // set original timestamp
            el.disconnectedCallback(); // stop auto-updates
        });
    }, 100); // YMMV, experiment with the timeout
})();

That's not very pretty but it seems to do the job.

like image 26
odony Avatar answered Oct 02 '22 16:10

odony


With a user stylesheet plugin (I'm using stylebot in chrome)

time {
  font-size: 0;
}
time:after {
    content: attr(data-original-title);
    font-size: 14px;
}
like image 38
chiliNUT Avatar answered Oct 02 '22 15:10

chiliNUT


Update 2021: a bookmarklet remains the only option on GitHub.
See for instance "Displaying Real Commit Times in GitHub" from Justin Noel

javascript:(function() {    
  var style = document.createElement('style');
  document.head.appendChild(style);
  var sheet = style.sheet;
  sheet.addRule('time-ago:before,relative-time:before', 'content: attr(title);display: block;font-size: 0.5rem;');  
})()

https://pbs.twimg.com/card_img/1432824610794393602/CE26XtQw?format=jpg&name=small


This contrasts with GitLab 14.1 (July 2021)

User setting to display absolute times

GitLab displays relative times (for example, 30 minutes ago) in a lot of places.

You can now change your user profile preferences to display absolute times instead, for example, ‘May 18, 2021, 3:57 PM.

Absolute times respect your browser settings and format dates and times based on your preferred locales, for example, British English over US English.

This new display option gives more information at a glance for users that need it for workflows like correlating actions in GitLab to external systems.

dd GitHub

See Documentation and Issue.

like image 41
VonC Avatar answered Oct 02 '22 14:10

VonC