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:
-
Go to Settings
→ Developer Settings
→ Personal access tokens
→ Fine-grained tokens
→ Click on Generate new token button. -
Select the repositories you want to share
-
Select the access level in Repository permissions.
For read-only access, you would want to set Contents to Read-only. -
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?