Create and clone a repository

Create a repository in Secure Source Manager and clone it to your local machine.

Before you begin

  1. Create or request access to a Secure Source Manager instance. For more information, see Create a Secure Source Manager instance.
  2. Install the Google Cloud CLI.
  3. To initialize the gcloud CLI, run the following command:

    gcloud init
  4. Install the alpha Google Cloud CLI component:
    gcloud components install alpha

Required roles

To get the permissions that you need to create a repository, ask your administrator to grant you the following IAM roles:

For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

For information on granting Secure Source Manager roles, see Access control with IAM and Grant users instance access.

Create a repository

Web interface

  1. To access the Secure Source Manager instance through its web interface, copy the following URL into your browser address bar.

    INSTANCE_ID-PROJECT_NUMBER.LOCATION.sourcemanager.dev

    Replace the following:

    • INSTANCE_ID with the instance name.
    • PROJECT_NUMBER with the instance's Google Cloud project number. For information on identifying projects, see Identifying projects.
    • LOCATION with the instance's region.
  2. Authenticate using your Secure Source Manager credentials if needed.

  3. Click the + Create new repository icon in the top right of the navigation menu.

  4. Fill out the repository details:

    1. Repository ID: Enter a name for the repository.

    2. Description: Optional. Description of the repository.

    3. Initialize repository: Optional. Select this option if you want to initialize the repository and add .gitignore, license, and README files.

    4. .gitignore: Optional. Choose which files to not track using the drop-down menu templates.

    5. license: Optional. Select a common license from the drop-down menu.

    6. Default branch: Name of the default branch.

  5. Click Submit.

The repository is created in your Secure Source Manager instance.

The Repo Admin role (roles/securesourcemanager.repoAdmin) is granted to you when you create a new repository. The new IAM permission might take up to 2 minutes to propagate, so if you get a permissions error when you try to access the repository after creation, wait a few minutes and try again.

Repositories you've created are listed in the Secure Source Manager web interface on the My repositories page.

Set up your credentials

Add the Secure Source Manager authentication helper to your global Git config by running the following command:

Linux

git config --global credential.'https://*.*.sourcemanager.dev'.helper gcloud.sh

Earlier versions of Git might not support wildcards. To add the authentication helper without wildcards, run the following command:

git config --global credential.'https://INSTANCE_ID-PROJECT_NUMBER-git.LOCATION.sourcemanager.dev'.helper gcloud.sh

Windows

git config --global credential.https://*.*.sourcemanager.dev.helper gcloud.cmd

Earlier versions of Git might not support wildcards. To add the authentication helper without wildcards, run the following command:

git config --global credential.https://INSTANCE_ID-PROJECT_NUMBER-git.LOCATION.sourcemanager.dev.helper gcloud.cmd

Replace the following:

  • INSTANCE_ID with the name of your Secure Source Manager instance.
  • PROJECT_NUMBER with your project number. For help finding your project number, see Identifying projects.
  • LOCATION with the instance's region. For more information on regions, see Locations.

The authentication helper uses the gcloud CLI to fetch your Google Cloud credentials when using Git commands with Secure Source Manager.

To re-authenticate after the initial credential setup, run the following gcloud CLI command:

gcloud auth login

Clone a repository

  1. In the Secure Source Manager web interface, navigate to your repository page.

  2. Copy the HTTPS URL at the top of your repository page.

  3. Clone your repository by running the following command:

    git clone REPOSITORY_URL
    

    Where REPOSITORY_URL is the HTTPS URL displayed at the top of the repository page you want to clone.

    Disregard the warning about cloning an empty repository.

Push to a repository

  1. In a terminal window, change directories into your cloned repository.

    cd REPOSITORY_NAME
    

    Where REPOSITORY_NAME is your repository name.

  2. Create an empty README file:

    touch README.md
    
  3. Add the README file to Git and create a commit message:

    git add README.md
    git commit -m "initial commit"
    
  4. Push your changes to your remote repository:

    git push -u origin main
    

    Git pushes the file from the main branch to the origin remote. The output is similar to the following:

    Enumerating objects: 3, done.
    Counting objects: 100% (3/3), done.
    Writing objects: 100% (3/3), 211 bytes | 211.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    remote: . Processing 1 references
    remote: Processed 1 references in total
    To https://instance-id-123456789012-git.us-central1.sourcemanager.dev/my-project/my-repo.git
    * [new branch]      main -> main
    branch 'main' set up to track 'origin/main'.
    

View your files in Secure Source Manager

In the Secure Source Manager web interface, click the name of your repository.

Your repository page opens and your README.md file is listed in the <> Code tab.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.

Before you remove the repository, ensure any files you want to keep are available in another location.

To delete your repository and all associated data, run the following command:

curl -X DELETE \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  https://INSTANCE_ID-INSTANCE_PROJECT_NUMBER-api.REGION.sourcemanager.dev/v1/projects/INSTANCE_PROJECT_NUMBER/locations/REGION/repositories/REPOSITORY_ID

Replace the following:

  • INSTANCE_ID: with the name of your Secure Source Manager instance.
  • INSTANCE_PROJECT_NUMBER: with the project number of your Secure Source Manager instance. See Identifying projects for information on where to find your project number.
  • REGION: with the region of your Secure Source Manager instance. See Locations for available regions.
  • REPOSITORY_ID: with the name of your repository.

The response resembles the following:

{"name":"operations/cc3ea26c-9b57-11ed-be0a-2e3b5910efef","metadata":{"@type":"type.googleapis.com/google.cloud.securesourcemanager.v1.OperationMetadata","createTime":"2023-01-23T19:54:49.904779921Z","endTime":"2023-01-23T19:54:50.947030402Z","target":"projects/my-project/locations/us-central1/repositories/my-repo","verb":"delete","apiVersion":"v1"},"done":true,"response":{"@type":"type.googleapis.com/google.protobuf.Empty"}

What's next