Is there anyway to programmatically fetch a zipball of private github repo?

Issue

We got a necessity to fetch a zipball of a private repo. For public ones it’s pretty easy either through GitHub API or manually (https://github.com/user/repo/zipball/master). But what about private repos? Not exactly obvious how to do it even having oAuth token.

Solution

New Alternative

Because the given accepted answer does not work anymore, I thought I would explain how I was able to do it with the new changes in the github API.

The new Download Api Link

First, I found information about downloading the archive here:
https://developer.github.com/v3/repos/contents/#get-archive-link

Public Repo

If it’s a public repo then it is very easy… you can do:

curl -L https://api.github.com/repos/pengwynn/octokit/tarball > octokit.tar.gz

Private Repo

If it’s it is a private repo, you need to create an oAuth token by going to your settings and then selecting “Developer settings” / “Personal access tokens“.
I created a personal token.

Then using the instructions on the following page I found out how to get private repo that you have permission to:
https://developer.github.com/v3/#authentication

Full Code

curl -H "Authorization: token ab499f3b..." \
-L https://api.github.com/repos/godzilla/my_priv_repo/tarball > wut.tar.gz

Be sure to replace ab499f3b... with your actual token.

Answered By – roychri

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published