How to Add Collaborators to Your GitHub Repo Easily
Learn how to add collaborators to your GitHub repositories using both the GitHub UI and API. Follow our guide to manage external contributions.
Learn how to add collaborators to your GitHub repositories using both the GitHub UI and API. Follow our guide to manage external contributions.
Coding projects often require many hands on deck, and GitHub is one of the most popular software development tools for teams to track versions and edit code in one unified location. Even in the free version of GitHub, project managers can add unlimited collaborators to private or public projects.
In this post, we’ll show you how to add Collaborators to your repository using the UI, a cURL CLI command, and the GitHub CLI.
Before adding collaborators, remember that there are guidelines around who can grant access to certain permission levels, even to public repositories.
To add someone, you need to be equal to or higher in permission level to the account being granted access. If a user attempts to give access to an account above their permission level, an error message will appear, saying:
"Cannot assign [member] permission of [role name]."
These guidelines exist for safety reasons. Inviting only collaborators you trust to make changes to your repository is crucial. Otherwise, someone intending to steal or hack the code might gain entry. Therefore, it's essential to grant permission only to those with the proper credentials and know-how to keep your project bug free and safe.
These steps below include images from GitHub's documentation.
1. In GitHub, navigate to the repository page and click Settings in the right hand corner.
2. In the sidebar, you’ll see an Access section with a Collaborators & teams option. Click through and you’ll see an Add people button to the right of Manage Access.
3. You can add a collaborator using either their username, full name, or email address.
4. Once you specify who you are inviting, you can select their level of permissions.
Once the invite is sent, the recipient receives a notification. At this point, the recipient can accept or decline the invite via email or the GitHub platform.
If you run into issues, it might be because of a policy for your Enterprise that restricts who can invite outside contributors.
You can see more details on viewing that policy information here.
You can add collaborators to a repository with the "PUT" operation using this endpoint:
/repos/{owner}/{repo}/collaborators/{username}
You’ll need to specify information for the following parameters:
You can run this with the GitHub CLI, JavaScript, or a cURL command. In these examples below, we’re adding someone with the permission level “triage”.
Here is the GitHub CLI code format to use:
When using JavaScript or a command, you’ll need to include your authentication token.
Here is the JS code format to use:
Here is the cURL command to use:
You will know you’ve successfully invited a collaborator to the repository if you receive a 201 status code response.
As we’ve just shown, it isn’t difficult to invite a collaborator to a repository using any of these methods, but it does require someone context-switching and manually inviting someone. What if you intend on onboarding collaborators regularly?
With Blink, you use no-code automations like this one to invite a collaborator to your repository. You can use conditional logic to assign their specific permissions, and send an email to your new collaborator with additional guidance.
You can also make it a self-service application, so others can submit new collaborators and kick off an approval process.
Import this automation from the Blink library into your account and customize it based on your organization’s needs. Just drag-and-drop new actions into the canvas.
Get started with Blink and automate your unique onboarding flows today.
Blink is secure, decentralized, and cloud-native. Get modern cloud and security operations today.