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.
What permissions do you need?
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.
Adding Collaborators via the GitHub UI
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.
Adding Collaborators Using the GitHub API
You can add collaborators to a repository with the "PUT" operation using this endpoint:
You’ll need to specify information for the following parameters:
- Owner Username
- Repository Name
- Username of the New Collaborator
- Permission Level
Here is the GitHub CLI code format to use:
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.
Inviting Collaborators with No-Code Steps in Blink
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 can build no-code automations to invite a collaborator to your repository, 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.
Create your free Blink account and automate your unique onboarding flows today.