Granting user access to repositories and projects

This topic describes how you can provide users access to repositories and projects, and what actions those users can take. Some examples user actions include:

  • Listing repositories
  • Creating new repositories
  • Updating repositories

For a complete list of actions, see Roles and Permissions Matrix.

Viewing repositories

Users with this level of permissions can view the contents of a repository. They can also clone and fetch the repository.

If granted this permission at the project level, users can view all repositories for that project.

Repository

Console:

  1. Open the My Source or All Repositories view.

  2. Select a repository.

    The File view opens.

  3. Select the Settings icon, located in the top right corner.

    The Settings screen opens.

  4. Click Permissions.

    The Permissions screen opens.

  5. Type the email address of the user in the Members box.

  6. From the Role list, select Source Repository.

  7. Select Source Repository Reader.

Command line:

  1. Open a terminal window.

  2. Type the following command:

    gcloud source repos set-iam-policy REPOSITORY_NAME POLICY_FILE [GCLOUD_WIDE_FLAG …]

    Where:

    • REPOSITORY_NAME is the name of the repository.
    • POLICY_FILE is the JSON or YAML file with the IAM policy.

For more information on this command, see gcloud source repos set-iam-policy.

Project

Console:

  1. Open the My Source or All Repositories view.

  2. Click the name of a project for a specific repository.

    The screen updates to display a list of all repositories for that project.

  3. Select the Settings icon, located in the top right corner.

    The Settings screen opens.

  4. Click Permissions.

    The Permissions screen opens.

  5. Type the email address of the user in the Members box.

  6. From the Role list, select Source Repository.

  7. Select Viewer.

Command line:

  1. Open a terminal window.

  2. Type the following command:

    gcloud projects add-iam-policy-binding PROJECT_ID --member=MEMBER \ --role=ROLE [GCLOUD_WIDE_FLAG …]

    Where:

    • PROJECT_ID is the ID for the project.
    • MEMBER is the user you want to add.
    • ROLE is the IAM role you want to assign.

For more information on this command, see gcloud projects add-iam-policy-binding.

Pushing repository commits

Users with this level of permissions can push changes to a repository, as well as perform all the actions described in Viewing repositories.

If granted this permission at the project level, users can push changes to all repositories in that project.

Repository

Console:

  1. Open the My Source or All Repositories view.

  2. Select a repository.

    The File view opens.

  3. Select the Settings icon, located in the top right corner.

    The Settings screen opens.

  4. Click Permissions.

  5. Type the email address of the user in the Members box.

  6. From the Role list, select Source Repository.

  7. Select Source Repository Writer.

Command line:

  1. Open a terminal window.

  2. Type the following command:

    gcloud source repos set-iam-policy REPOSITORY_NAME POLICY_FILE [GCLOUD_WIDE_FLAG …]
    

    Where:

    • REPOSITORY_NAME is the name of the repository.
    • POLICY_FILE is the JSON or YAML file with the IAM policy.

For more information on this command, see gcloud source repos set-iam-policy.

Project

Console:

  1. Open the My Source or All Repositories view.

  2. Click the name of a project for a specific repository.

    The screen updates to display a list of all repositories for that project.

  3. Select the Settings icon, located in the top right corner.

    The Settings screen opens.

  4. Click Permissions.

    The Permissions screen opens.

  5. Type the email address of the user in the Members box.

  6. From the Role list, select Source Repository.

  7. Select Source Repository Writer.

Command line:

  1. Open a terminal window.

  2. Type the following command:

    gcloud projects add-iam-policy-binding PROJECT_ID --member=MEMBER \
    --role=ROLE [GCLOUD_WIDE_FLAG …]
    

    Where:

    • PROJECT_ID is the ID for the project.
    • MEMBER is the user you want to add.
    • ROLE is the IAM role you want to assign.

For more information on this command, see gcloud projects add-iam-policy-binding.

Creating and deleting repositories

If granted this permission at the project level, users can create, update, and delete repositories for the entire project.

  1. Open the My Source or All Repositories view.

  2. Click the name of a project for a specific repository.

    The screen updates to display a list of all repositories for that project.

  3. Select the Settings icon, located in the top right corner.

    The Settings screen opens.

  4. Click Permissions.

    The Permissions screen opens.

  5. Type the email address of the user in the Members box.

  6. From the Role list, select Source Repository.

  7. Select Source Repository Administrator.

Removing user access

Repository

Console:

  1. Open the My Source or All Repositories view.

  2. Select a repository.

    The File view opens.

  3. Select the Settings icon, located in the top right corner.

    The Settings screen opens.

  4. Click Permissions.

  5. Locate the role you want to remove.

  6. Click the trash can icon for that role.

    A confirmation dialog box opens.

  7. Click Remove.

Project

Console:

  1. Open the My Source or All Repositories view.

  2. Click the name of a project for a specific repository.

    The screen updates to display a list of all repositories for that project.

  3. Select the Settings icon, located in the top right corner.

    The Settings screen opens.

  4. Click Permissions.

    The Permissions screen opens.

  5. Locate the role you want to remove.

  6. Click the trash can icon for the role.

    A confirmation dialog box opens.

  7. Click Remove.

What's next

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Source Repositories