43

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.

44

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).

  • 3
    Doesn't work if the repo has too many forks. – Mike McKay May 22 '15 at 21:10
  • 3
    "Network" is found under the "Graphs" side tab (just in case) – Jedidja May 30 '15 at 14:12
  • Doesn't work if the default branch doesn't have the earliest commit. – OrangeDog Dec 6 '16 at 10:55
  • There's a similar question on Stack Overflow. Would you mind cross-posting this answer? – Stevoisiak Mar 16 '18 at 13:22
14

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.-

12

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'

"Contributors" tab in "Graphs"

  • If you select the very left edge of the graph using the brush, then click on the # commits for the first committer, you'll actually see the commits. – Gordon Oct 18 '16 at 12:20
  • @Gordon that is not very helpful, it just shows all commits for that person – Steven Penny Nov 30 '16 at 1:33
  • @StevenPenny, the question was just how to get the date of the first commit. Granted, it's messy, but if you select just the very left edge, you'll see the first commit. I prefer the dedicated site I linked in my answer below. – Gordon Nov 30 '16 at 1:49
  • Doesn't work if the default branch doesn't have the earliest commit. – OrangeDog Dec 6 '16 at 10:55
  • This is the best – Code Whisperer Jan 30 '17 at 14:55
1

This will get you the last page:

#!/bin/sh
url=https://github.com/$1/$2/commits?page=
up=1
while :
do
  printf '%s%d\t' $url $up
  if wget -q --spider $url$up
  then
    echo OK
    lw=$up
    up=$((up * 2))
  else
    echo Not Found
    break
  fi
done
while :
do
  k=$(((lw + up) / 2))
  if [ $k = $lw ]
  then
    break
  fi
  printf '%s%d\t' $url $k
  if wget -q --spider $url$k
  then
    echo OK
    lw=$k
  else
    echo Not Found
    up=$k
  fi
done

Example:

$ github.sh 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

Source

1

Here's a site that only searches for the first commit on GitHub, avoiding the problems with long commit histories and too many forks:

http://first-commit.com/

Discussion on Hacker News.

... Which notes that this is just scraping the web site, and calculating what page to jump to. It would be far better to use the API.

  • 1
    Doesn't work if the default branch doesn't have the earliest commit. – OrangeDog Dec 6 '16 at 10:55
0

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.

-1

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:

enter image description 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.

  • 10
    I already knew that. The question was for projects with very long commit histories. – Randomblue May 3 '13 at 7:35
-2
git log --reverse --format="format:%ci" | sed -n 1p

If you want to get it from a command line

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.