gitgithub

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.


Solution

  • 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.