33

While I definitely am not the owner of this private repo, I have been using it as part of a group for a school project, and the teacher is simply asking for the Repo's ID when sending him emails concerning anything. I'm sorry if this is blatantly obvious to a lot of people, but for the life of me I could not find any clear notes on this via github or google. I am not using a GUI for my git, strictly through a linux shell.

How do I find out the ID of the current Repo?

Toby Allen
  • 10,997
  • 11
  • 73
  • 124

6 Answers6

122

If, like me, you were after the GitHub repository ID (as in - the number identifying the repo - not its name), then I found an easy way to do this via the metadata element on the main page of the repository on GitHub:

  1. View the page source (Right Click > View Page Source in Chrome or Firefox for example)
  2. Search the page source and look for octolytics-dimension-repository_id. You should find something that looks like:

    <meta content="123456789" name="octolytics-dimension-repository_id" />

In this example, the ID of the repository is 123456789.

Arnaud Valle
  • 1,673
  • 1
  • 16
  • 25
18

Here's a quick query you can run in console:

$("meta[name=octolytics-dimension-repository_id]").getAttribute('content')

Rimian
  • 36,864
  • 16
  • 117
  • 117
5

Nine years later, using the graphql API, there is an awesome explorer

  1. Login
  2. Paste the following query
  3. Replace repo_name, owner_name with real values
  4. click play
query {
  repository (name: *repo_name*, owner: *owner_name*)  {
        id
  }
}

That is all.

Oded
  • 171
  • 1
  • 11
  • Plus one it works without signing in / `Personal Access Token`. Do use double quotes around `repo` and `user` – Timo Nov 24 '22 at 21:06
  • I believe the right field in the repository object is `databaseId` - not `id` – jdgilday Aug 06 '23 at 03:17
3

Your repository on GitHub does have a unique ID and it can be obtained using the following simple bash script:

#!/bin/bash
OWNER='your github username or organization name'
REPO_NAME='your repository name'    
echo $(gh api -H "Accept: application/vnd.github+json" repos/$OWNER/$REPO_NAME) | jq .id

Note: you will need to install both jq and github cli to get this to work.

Eyal Gerber
  • 1,026
  • 10
  • 27
2

When you say "repo ID", do you mean the URL of the repo on GitHub?

If that's what you're looking for, use git remote.

plankton:~/scraps $ git remote -v
origin  git@github.com:petdance/scraps.git (fetch)
origin  git@github.com:petdance/scraps.git (push)

If you have multiple remote repos feeding into your local repository, all of them will be listed there.

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
  • 2
    Thank you. I for some odd reason assumed that I was looking for some sort of obscure integer/character combination. I think I got confused because branches or commits have those kinds of codes? –  Dec 16 '12 at 15:37
  • Each commit in git has a SHA1 (pronounced like "shah", without the "one" spoken). So if you do a `git log`, each commit is uniquely identified like so: `commit 1351eb148fa6a4631d6fbc24faf95ca0be62d72f` In many cases, it's enough to use only the first six digits of the SHA1 to uniquely identify the commit in the repo. – Andy Lester Dec 16 '12 at 17:16
-3

I guess he was talking about name/reponame combination (which uniquely identifies repo on github), e.g. if you using the following string in your git remote

git://github.com/sublimescala/sublime-ensime.git

The id will be sublimescala/sublime-ensime

om-nom-nom
  • 62,329
  • 13
  • 183
  • 228