Is there any command or an API through which I can know who forked my git repository (Present on github.com). I know this is simple using UI (of github.com) but I would prefer to do it command line (using git bash or through any other command line utility).
-
Are you talking about the Github API? – awendt Feb 27 '17 at 12:51
-
@awendt Can't it be done using git bash only. – BeginnersSake Feb 27 '17 at 12:54
-
4@BeginnersSake - the idea of "forking" is not a git term - it is only related to github (or other services that manage version control). The only way you'd be able to get that info is to ask github - its not stored as part of your version controlled code. – Lix Feb 27 '17 at 12:55
3 Answers
This is possible using the GitHub API.
To get a list of forks for a given repository, issue a GET request to https://api.github.com/repos/<user>/<repository>/forks
. The result is a JSON document containing, among lots of other information, the users who forked the repository.
From a Linux shell:
$ curl https://api.github.com/repos/<user>/<repository>/forks
Parsing the resulting JSON can be done, for example, with a simple Python script (using Python 3):
#!/usr/bin/env python3
from urllib.request import urlopen
import json
def fork_users(user, repo):
url = 'http://api.github.com/repos/{u}/{r}/forks'.format(u=user, r=repo)
with urlopen(url) as r:
forks = json.loads(r.read().decode('utf8'))
return [f['owner']['login'] for f in forks]
if __name__ == '__main__':
from sys import argv
user, repo = argv[1:3]
for user in sorted(fork_users(user, repo)):
print(user)
For other options, see for example this question.
Forking is not a part of the official git language but rather of github, and therefore it is not possible using git bash.

- 1,067
- 7
- 13
As mentioned by @Englund fork is not part of git, but if you are looking for a command line utility to identify all the forks - https://github.com/frost-nzcr4/find_forks which use the API - https://developer.github.com/v3/repos/forks/

- 1,506
- 13
- 19