CREATE GIT REPOSITORY¶
Creates a Git repository stage in the schema or replaces an existing Git repository stage.
- See also:
ALTER GIT REPOSITORY, DESCRIBE GIT REPOSITORY, DROP GIT REPOSITORY, SHOW GIT BRANCHES, SHOW GIT REPOSITORIES, SHOW GIT TAGS
Syntax¶
CREATE [ OR REPLACE ] GIT REPOSITORY [ IF NOT EXISTS ] <name>
ORIGIN = '<repository_url>'
API_INTEGRATION = <integration_name>
[ GIT_CREDENTIALS = <secret_name> ]
[ COMMENT = '<string_literal>' ]
[ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] ) ]
Required parameters¶
name
Specifies the identifier for the repository stage to create.
If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.
For more information, see Identifier requirements.
ORIGIN = 'repository_url'
Specifies the origin URL of the Git repository that this repository stage represents.
The URL must use HTTPS.
From the command line, you can use the
git config
command from within your local repository to get the value to use for the ORIGIN parameter, as shown in the following example:$ git config --get remote.origin.url https://github.com/mycompany/My-Repo.git
API_INTEGRATION = integration_name
Specifies the API INTEGRATION that contains information about the target Git repository such as allowed credentials and prefixes for target URLs.
The API integration you specify here must have an API_PROVIDER parameter whose value is set to
git_https_api
.For reference information about API integrations, see CREATE API INTEGRATION.
Optional parameters¶
GIT_CREDENTIALS = secret_name
Specifies the Snowflake secret containing the credentials to use for authenticating with the repository. Omit this parameter to use the default secret specified by the API integration or if this integration does not require authentication.
As a best practice, use a personal access token for the secret’s PASSWORD value. For information about creating a personal access token in GitHub, see Managing your personal access tokens (https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) in the GitHub documentation.
The secret you specify here must be a secret specified by the ALLOWED_AUTHENTICATION_SECRETS parameter of the API integration you specify with this command’s API_INTEGRATION parameter.
Default: No value
For reference information about secrets, see CREATE SECRET.
COMMENT = 'string_literal'
Specifies a comment for the external access integration.
Default: No value
TAG ( tag_name = 'tag_value' [ , tag_name = 'tag_value' , ... ] )
Specifies the tag name and the tag string value.
The tag value is always a string, and the maximum number of characters for the tag value is 256.
For information about specifying tags in a statement, see Tag quotas for objects and columns.
Access control requirements¶
A role used to execute this SQL command must have the following privileges at a minimum:
Privilege |
Object |
Notes |
---|---|---|
CREATE GIT REPOSITORY |
Schema |
|
USAGE |
API integration |
The integration specified by this command’s API INTEGRATION parameter |
USAGE |
Secret |
The secret specified by this command’s GIT_CREDENTIALS parameter |
The USAGE privilege on the parent database and schema are required to perform operations on any object in a schema.
For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.
For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
Examples¶
Code in the following example creates a Git repository stage called snowflake_extensions
, where the repository’s origin URL
is https://github.com/my-account/snowflake-extensions.git
. The example uses an API integration called git_api_integration
,
along with a secret called git_secret
to store credentials for authenticating with the repository.
For details about setting up integration with a repository, see Setting up Snowflake to use Git.
CREATE OR REPLACE GIT REPOSITORY snowflake_extensions
API_INTEGRATION = git_api_integration
GIT_CREDENTIALS = git_secret
ORIGIN = 'https://github.com/my-account/snowflake-extensions.git';