Restrict users who are member to see my private github repos

how to share private Github repos with users who are logged in and members of my forum.
Is it even possible. or is there a way around how to achieve this. ?
Any guidance appreciated

To share a private GitHub repository through a browser, a user must have a GitHub account and be added as a collaborator. See Inviting collaborators to a personal repository - GitHub Docs.

If sharing a GitHub link for cloning is acceptable, you can create a fine-grained (e.g., read-only) personal access token. This token will allow others to access it only through git (clone).
For example: git clone https://<username>:<token>@github.com/<username>/<repo>

How to generate a new token:
  1. Go to Settings
    → Developer Settings
    → Personal access tokens
    → Fine-grained tokens
    → Click on Generate new token button.

    Or Go to https://github.com/settings/personal-access-token :smile:

  2. Select the repositories you want to share

  3. Select the access level in Repository permissions.
    For read-only access, you would want to set Contents to Read-only.

  4. Click on Generate token, you’re done!

It depends on what kind of access you’re looking for, if temporary access, whether you are a small/big community.

For example, you will not manually add every user if you are a large community. Creating a plugin to add/remove a collaborator through the GitHub API automatically is possible, but that doesn’t seem like a good long-term solution. You might need to create a snapshot of the repository and share it another way.

By member, do you mean behind a subscription or just logged in?
Do you think you could elaborate more about your context?

3 Likes

Your solution i am currently using to achieve this.

git - Can I share my private GitHub repository by link? - Stack Overflow

Just logged in.
But i needed something robust. but i have no idea how to approach this.
My forum is a closed forum.

1 Like