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. Examples of user actions include the following:

  • Listing repositories
  • Creating new repositories
  • Updating repositories

For a complete list of actions, see Roles and permissions matrix.

Grant permissions to view 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.

Grant viewing permissions for a repository

Console

  1. In the Google Cloud Console, open Cloud Source Repositories.

    Open Cloud Source Repositories

    The All repositories page opens. Alternatively, you can open the My source view.

  2. Click the name of a repository.

    The Files view opens.

  3. Click Settings .

    The General settings page opens.

  4. Click Permissions.

    The Permissions page opens.

  5. In the Members field, enter the user's email address.

  6. In the Role drop-down list, select Source repository > Source Repository Reader.

  7. Click Add.

Command line

  1. Open a terminal window.

  2. Enter the following command:

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

    Where:

    • [REPO_NAME] is the name of the repository.
    • [POLICY_FILE] is the JSON or YAML file with the Cloud Identity and Access Management policy.

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

Grant viewing permissions across a project

Console

  1. In the GCP Console, open Cloud Source Repositories.

    Open Cloud Source Repositories

    The All repositories page opens. Alternatively, you can open the My source view.

  2. Click the name of a Google Cloud project ID for a specific repository.

    The page displays a list of all repositories for that project.

  3. Click Settings .

    The General settings page opens.

  4. Click Permissions.

    The Permissions page opens.

  5. In the Members field, enter the user's email address.

  6. In the Role drop-down list, select Source repository > Source Repository Reader.

  7. Click Add.

Command line

  1. Open a terminal window.

  2. Enter 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 your Google Cloud project.
    • [MEMBER] is the user you want to add.
    • [ROLE] is the Cloud IAM role you want to assign.

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

Grant permissions to push commits

Users with this level of permissions can push changes to a repository. They can also 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.

Grant push permissions for a repository

Console

  1. In the GCP Console, open Cloud Source Repositories.

    Open Cloud Source Repositories

    The All repositories page opens. Alternatively, you can open the My source view.

  2. Click the name of a repository.

    The Files view opens.

  3. Click Settings .

    The General settings page opens.

  4. Click Permissions.

    The Permissions page opens.

  5. In the Members field, enter the user's email address.

  6. In the Role drop-down list, select Source repository > Source Repository Writer.

  7. Click Add.

Command line

  1. Open a terminal window.

  2. Enter the following command:

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

    Where:

    • [REPO_NAME] is the name of the repository.
    • [POLICY_FILE] is the JSON or YAML file with the Cloud IAM policy.

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

Grant push permissions for a project

Console

  1. In the GCP Console, open Cloud Source Repositories.

    Open Cloud Source Repositories

    The All repositories page opens. Alternatively, you can open the My source view.

  2. Click the name of a Google Cloud project ID for a specific repository.

    The page displays a list of all repositories for that project.

  3. Click Settings .

    The General settings page opens.

  4. Click Permissions.

    The Permissions page opens.

  5. In the Members field, enter the user's email address .

  6. In the Role drop-down list, select Source Repository > Source Repository Writer.

  7. Click Add.

Command line

  1. Open a terminal window.

  2. Enter 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 your Google Cloud project.
    • [MEMBER] is the user you want to add.
    • [ROLE] is the Cloud IAM role you want to assign.

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

Grant permissions to create and delete repositories

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

  1. In the GCP Console, open Cloud Source Repositories.

    Open Cloud Source Repositories

    The All repositories page opens. Alternatively, you can open the My source view.

  2. Click the name of a Google Cloud project ID for a specific repository.

    The page displays a list of all repositories for that project.

  3. Click Settings .

    The General settings page opens.

  4. Click Permissions.

    The Permissions page opens.

  5. In the Members field, enter the user's email address.

  6. In the Role drop-down list, select Source repository > Source Repository Administrator.

  7. Click Add.

Remove a user's access

There may be cases where you need to remove a user's access to a repository or project.

Remove access to a repository

  1. In the GCP Console, open Cloud Source Repositories.

    Open Cloud Source Repositories

    The All repositories page opens. Alternatively, you can open the My source view.

  2. Click on the name of a repository.

    The Files view opens.

  3. Click Settings .

    The General settings page opens.

  4. Click Permissions.

  5. Locate the role you want to remove, and then click Delete for that role.

    A confirmation dialog opens.

  6. Click Remove.

Remove access to a project

  1. In the GCP Console, open Cloud Source Repositories.

    Open Cloud Source Repositories

    The All repositories page opens. Alternatively, you can open the My source view.

  2. Click the name of a Google Cloud project ID for a specific repository.

    The page displays a list of all repositories for that project.

  3. Click Settings .

    The General settings page opens.

  4. Click Permissions.

    The Permissions page opens.

  5. Locate the role you want to remove, and then click Delete for that role.

    A confirmation dialog opens.

  6. Click Remove.

What's next

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

Send feedback about...

Cloud Source Repositories Documentation