Given a GitHub repository, how can I quickly find the date of its first commit?
I often want to know how old the project is, but I cannot find a quick way to get to the start of the commit histories for projects with very long commit histories.
Web Applications Stack Exchange is a question and answer site for power users of web applications. It only takes a minute to sign up.
Sign up to join this communityGiven a GitHub repository, how can I quickly find the date of its first commit?
I often want to know how old the project is, but I cannot find a quick way to get to the start of the commit histories for projects with very long commit histories.
Click on the "Insights" tab of the repository that you want to see the oldest commit, followed by the "Network" sub-tab on the left menu bar. When the page is fully loaded (i.e. you can see lots of lines joining and all), press Shift+← to go all the way to the first commit. Click on the dot that represents the first commit and you can get it.
Note: This only works for repositories that was created on GitHub originally, not repositories that were imported from another place (i.e. commits not registered through GitHub itself). Also, this method may not necessarily work if the repository has too many forks.
Alternatively, you can clone the repository to your local machine and run the following command:
git log --reverse
The repository's commits will then be shown in reverse order (oldest commit first).
-1
doesn't work with --reverse
to get the oldest commit because the limit happens before the filter.
– Quolonel Questions
Oct 17 '19 at 9:22
If you have cloned the repo, just use git commands as usual:
// cd to repo
$ git log --reverse
it will show you the history of commits in reverse order. LOL.-
Hydra's answer may not work with projects that have a lot of forks: "Couldn't load network graph. Too many forks to display."
You can check the 'Contributors' tab under 'Graphs'
This will get you the last page:
<?php
$s_url = $argv[1] . '/commits?page=';
$n_hi = 1;
while (true) {
$s_hi = sprintf('%s%d', $s_url, $n_hi);
echo $s_hi, "\t";
$s_get = file_get_contents($s_hi);
if (strpos($s_get, 'No commits found') !== false) {
echo "Not Found\n";
break;
}
echo "OK\n";
$n_lo = $n_hi;
$n_hi *= 2;
}
while (true) {
$n_mid = intdiv($n_lo + $n_hi, 2);
if ($n_mid == $n_lo) {
break;
}
$s_mid = sprintf('%s%d', $s_url, $n_mid);
echo $s_mid, "\t";
$s_get = file_get_contents($s_mid);
if (strpos($s_get, 'No commits found') !== false) {
echo "Not Found\n";
$n_hi = $n_mid;
} else {
echo "OK\n";
$n_lo = $n_mid;
}
}
Example:
PS C:\> git.php https://github.com/jp9000/OBS
https://github.com/jp9000/OBS/commits?page=1 OK
https://github.com/jp9000/OBS/commits?page=2 OK
https://github.com/jp9000/OBS/commits?page=4 OK
https://github.com/jp9000/OBS/commits?page=8 OK
https://github.com/jp9000/OBS/commits?page=16 OK
https://github.com/jp9000/OBS/commits?page=32 OK
https://github.com/jp9000/OBS/commits?page=64 OK
https://github.com/jp9000/OBS/commits?page=128 Not Found
https://github.com/jp9000/OBS/commits?page=96 Not Found
https://github.com/jp9000/OBS/commits?page=80 Not Found
https://github.com/jp9000/OBS/commits?page=72 OK
https://github.com/jp9000/OBS/commits?page=76 OK
https://github.com/jp9000/OBS/commits?page=78 OK
https://github.com/jp9000/OBS/commits?page=79 OK
You can use unix sed tool for filtering just the date of the first commit using
git log --reverse | sed -n -e "3,3p"
I think it is exactly you need.
There is a way to do it from the GitHub interface itself.
Go the the project page and pick the Code
tab followed by the Commits
sub-tab as shown here:
That brings you to your list of commits. If you then scroll to the bottom of the page, you can keep going back in time by clicking the Older
button.
I couldn't really find a way to sort it so that the commits shown in ascending order.
git log --reverse --format="format:%ci" | sed -n 1p
If you want to get it from a command line
None of the solutions listed above worked for me. git log --reverse
does not work if there are a lot of forks in your tree. The script mentioned by @steven-penny did not work because github changed their urls to use a hash for the after
query param value when browsing commints /master?after=Y3Vyc29yOvqNPhkVDBdTgRaxBYnOx1jBe88LKzM0
and neither did any of the graphs for the repo.
So what did work for me was quite simple. gitk
. Using gitk
and scrolling down to the last commit gave me the information I was looking.
Hope this helps other folks looking for similar info.
git log --reverse
will show commits from earliest to most recent – batpigandme May 2 '13 at 19:51