gaRos
gaRos

Reputation: 2773

Can I share my private GitHub repository by link?

I have a Java application in a private repository on GitHub and I would like to share it with someone who doesn't have an account. I didn't find any option on the site for this.

Is there a way to do this? Collaborators can be only GitHub users.

Upvotes: 190

Views: 341063

Answers (5)

Robin Winslow
Robin Winslow

Reputation: 11502

Generate an invitation URL with a 1-week lifespan

Here's a hacky way of creating an invite link for a private repo.

This will (at the time of writing) generate an invitation link for someone to either login or create a new account to access your repository. The link will last for 7 days.

  1. Get a temporary email address - e.g. using https://temp-mail.org/
  2. In your repository, go to "Settings" -> "Collaborators and teams" -> "Add people", enter the temporary email address, click "Invite to {your repo}" enter image description here
  3. Select the permission level you want this invite link to have, and click "Add {email}"
  4. In your temporary mailbox, you should receive the email containing an invitation link: enter image description here
  5. Right click on "View invitation" and copy the link.

This link should look something like:

https://github.com/{username}/{repository}/invitations?invitation_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Even though this was generated for the temporary email address, anyone can create an account with any email through this link.

You now have a link you can share with anyone to give them access to your repository.

Upvotes: 2

nguyendown
nguyendown

Reputation: 795

You can use read-only access token to share a private repository.

git clone https://<username>:<token>@github.com/<username>/<repo>.git

To generate a new token:

  1. Under your user profile go to Settings > Developer Settings > Personal access tokens > Fine-grained tokens > Generate new token.

  2. Select the repositories you want to share under Repository access > Only select repositories.

  3. Set the access level of the token to read-only in Permissions > Repository permissions > Contents > Access: read-only.

  4. Finally, click on Generate token.

Upvotes: 68

Jaime
Jaime

Reputation: 1631

Use https://gitfront.io/. The steps to follow are:

  1. Visit the https://gitfront.io/ page and click on Get Started.
  2. Click on Add Repository.
  3. Copy the link to the private repository you want to share using SSH. It should look something like [email protected]:your_username/repo_name.git

SSH Link on github

  1. Paste it where it says Repository URL. Press Add.

Repository Form in gitfront

  1. Copy the key shown in the text box and click on Open repository Deploy keys on GitHub.

Key generation on gitfront

  1. Add the deploy key to github.

Add a deploy key on github

  1. Hit Build and it will generate a url that you can view and share by clicking the View button.

Upvotes: 71

Karthik SWOT
Karthik SWOT

Reputation: 1217

You can use gitfront.io for this purpose. You can give users to read-only access to keep your secure

Upvotes: 67

Tomas Votruba
Tomas Votruba

Reputation: 24298

There is no way to share private repository among non-Github users.

You need the Github account and be added as collaborator to the project.

Upvotes: 132

Related Questions