Give someone access to a private repo
Let one specific person into your private repo so they can read it, copy it, and contribute — without making it public.
Time: ~1 min on your side; they accept with one click. You'll need: their GitHub username (best) or a verified email. Last verified: 2026-06-07
Before you begin
You need three things in place. Each is a one-time setup, linked below:
- Claude Code set up — the agent that runs the command for you (~10 min, once).
- The GitHub CLI connected — so the agent can act on your account (~3 min, once).
- The other person's GitHub username — e.g.
alice. An email also works, but only if it's verified on their account (more on that below), so the username is the safe bet.
New to all this? Start at Create a GitHub account, then Set up Claude Code; come back here once claude runs.
The default: ask your agent
In the repo's folder, run claude and say:
Invite the GitHub user alice as a collaborator on this repo.
It runs gh api -X PUT repos/{owner}/{repo}/collaborators/alice — you only supply the username. [confirmed] The endpoint is PUT /repos/{owner}/{repo}/collaborators/{username}; default access is read-and-write (push), and the person must accept the invite before anything happens. To grant read-only instead, add: "give them read access only."
What happens next
- They get an invite — an email plus a GitHub notification ("you've been invited to collaborate on…").
- They click Accept. That's their whole job — one click, no command line.
- They're in. From there they can read every file, copy the whole thing, and contribute back.
To remove someone
Just say "remove alice as a collaborator on this repo." Access stops at once — but anything they already copied stays on their machine; revoking doesn't reach into their copy.
Two catches
- Email invites need a verified email. If you invite by email, it only lands if that exact address is verified on their GitHub account.
[confirmed]When in doubt, use the username. - The invite expires after 7 days.
[confirmed]If they don't accept in time, just ask your agent to invite them again.
Sharing with a whole group
Inviting people one at a time gets old fast. For more than a handful, put them in a GitHub organization and grant access by team — one setup, then everyone added to the team gets in automatically.
Prefer to do it by hand?
- On the repo page, go to Settings → Collaborators (under "Access").
- Click Add people, type their username, full name, or email, pick them from the list.
- They get the invite and accept — same as above.
If it doesn't work
- "They never got the invite" → check you used the right handle. An email invite silently fails unless that email is verified on their account — re-send to their username instead.
[confirmed] - "The invite expired" → it lapses after 7 days; ask your agent to invite them again (it re-sends a fresh one).
[confirmed] gh: Not Found (HTTP 404)→ the agent is pointed at the wrong repo, or the CLI isn't logged in to the account that owns it. Rungh auth statusto check who you are; re-auth with the GitHub CLI if needed.HTTP 403/ "Resource not accessible" → your login doesn't have admin rights on that repo (you can only add collaborators to repos you own or administer).- "They accepted but still can't push" → default access is read-and-write, but if you granted read-only, they can read and copy but not contribute. Ask your agent to "give alice write access."
- More than a handful of people → don't invite one by one; use an organization and teams instead.
Watch / read
Best written walkthrough: GitHub's own guide, Inviting collaborators to a personal repository — the authoritative by-hand steps, kept current.
Short videos (the by-hand path; all under ~3 min — transcripts couldn't be verified from this machine this session, so titles/channels are the signal):
- How to Add Collaborators to a GitHub Repository Step by Step — AyyazTech — 3:08 — plain, complete walk through Settings → Collaborators → Add people.
- How To Give Access To A Private GitHub Repository — Just Kristers — 2:08 — titled for exactly this task (private repo), recent.
- How to Give Read Only Access to a Private Repository — The Code City — 4:03 — covers the read-only variant if you don't want them contributing.
Sources
- Inviting collaborators to a personal repository — GitHub Docs (by-hand UI steps)
- Add a repository collaborator (REST API) — GitHub Docs (the
PUTendpoint, accept-required, defaultpush) - Inviting users to join your organization — GitHub Docs (email must match a verified address)
- Self-expiring repository and organization invitations — GitHub Changelog (7-day expiry)
gh apimanual — GitHub CLI (the-X PUTrequest pattern)