Is there a way to get download/clone statistics of a git repository?

GitGithub

Git Problem Overview


Is there any way to get how many times a git repository has been cloned or downloaded from github? I was just curious as I found other statistics such as commit times lines of codes cam be generated using: http://gitstats.sourceforge.net/ but I did not find how to check for clone/download count.

Git Solutions


Solution 1 - Git

Its super easy now!

Go "REPO -> Insights -> Traffic"

enter image description here

Solution 2 - Git

Cloning is a read-only operation, the original repository isn't modified. There is no way you can pull statistics for data that simply isn't tracked.

Solution 3 - Git

I just find out there is an even simpler way to get it with a single command using the github API.

curl -u [username]:[password] https://api.github.com/repos/[owner]/[repo]/traffic/clones

here:

username  = your github id
password  = your github password, optional. If not put in command, a password request would pop out.
owner     = the owner of the repo, might be another name for a organized repo
repo      = the repo name

Have fun.

Solution 4 - Git

Regarding download statistics, you can get information about your Releases via the API.

For those using WordPress, I developed this plugin: GitHub Release Downloads. It allows you to get the download count, links and more information for releases of GitHub repositories.

To address the original question, the shortcode [grd_count user="User" repo="MyRepo"] will return the number of downloads for a repository. This number corresponds to the sum of all download count values of all releases for one GitHub repository.

Example: Example

Solution 5 - Git

Actual clone counts are available via the Clone Graphs feature, which I've been able to scrape to get the individual counts:

#!/bin/sh
#
# This script requires:
#   apt-get install html-xml-utils
#   apt-get install jq
#
USERNAME=dougluce
PASSWORD="PASSWORD GOES HERE, BE CAREFUL!"
REPO="dougluce/node-autovivify"

TOKEN=`curl https://github.com/login -s -c /tmp/cookies.txt | \
     hxnormalize | \
     hxselect 'input[name=authenticity_token]' 2>/dev/null | \
     perl -lne 'print $1 if /value=\"(\S+)\"/'`

curl -X POST https://github.com/session \
     -s -b /tmp/cookies.txt -c /tmp/cookies2.txt \
     --data-urlencode commit="Sign in" \
     --data-urlencode authenticity_token="$TOKEN" \
     --data-urlencode login="$USERNAME" \
     --data-urlencode password="$PASSWORD" > /dev/null

curl "https://github.com/$REPO/graphs/clone-activity-data" \
     -s -b /tmp/cookies2.txt \
     -H "x-requested-with: XMLHttpRequest" #| jq '.summary'

Solution 6 - Git

You can use shields.io which provides icon bars that displays counts for projects in various websites including Github. They display the download counts, but not the clone counts.

Here's an example for a project I have:

Markdown Code:

![GitHub All Releases](https://img.shields.io/github/downloads/lewdev/hw-gen/total)

Result:

GitHub All Releases

Nobody "downloads" my app because it's already published, but people do clone it. So I'd rather see the counts for that.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionShreyas KarnikView Question on Stackoverflow
Solution 1 - GitFarhanView Answer on Stackoverflow
Solution 2 - Gituser229044View Answer on Stackoverflow
Solution 3 - GitWei SongView Answer on Stackoverflow
Solution 4 - GitIvanRFView Answer on Stackoverflow
Solution 5 - GitAllen LuceView Answer on Stackoverflow
Solution 6 - GitlewdevView Answer on Stackoverflow