设置 Git 存储库¶
您可以将远程 Git 存储库与 Snowflake 集成,以便将存储库中的文件同步到一种称为 存储库暂存区 的特殊暂存区。存储库暂存区充当本地 Git 存储库,其中包含远程存储库的完整克隆,包括分支、标签和提交。
有关更多信息,请参阅 在 Snowflake 中使用 Git 存储库。
准备工作¶
在设置 Git 存储库之前,您需要以下信息:
远程存储库的 URL(在 Git 中也称为
origin
)。用于连接到 Git 的可选凭据,包括密钥、用户名和密码。
可选的 API 集成 ID。
具有创建 API 集成权限的角色或用户(如果您还没有 API 集成)。
有关此信息的详细信息,请参阅 创建包含用于身份验证的凭据的密钥。
设置 Git 存储库¶
要将 Git 存储库克隆到 Git 存储库暂存区,请使用 snow git setup
命令,如下所示:
snow git setup <REPO_NAME>
其中:
<REPO_NAME>
是您要创建的存储库暂存区的 ID。请注意,如果存储库暂存区已经存在,则命令失败。
snow git setup
命令提供用于收集必要信息的一系列提示,如以下示例所示:
创建需要密钥和凭据的存储库:
$ snow git setup snowcli_git Origin url: https://github.com/snowflakedb/snowflake-cli.git Use secret for authentication? [y/N]: y Secret identifier (will be created if not exists) [snowcli_git_secret]: new_secret Secret 'new_secret' will be created username: john_doe password/token: **** API integration identifier (will be created if not exists) [snowcli_git_api_integration]:
Secret 'new_secret' successfully created. API integration snowcli_git_api_integration successfully created. +------------------------------------------------------+ | status | |------------------------------------------------------| | Git Repository SNOWCLI_GIT was successfully created. | +------------------------------------------------------+
创建一个没有密钥和现有 API 集成 ID 的存储库:
$ snow git setup snowcli_git Origin url: https://github.com/snowflakedb/snowflake-cli.git Use secret for authentication [y/N]: n API integration identifier (will be created if not exists) [snowcli_git_api_integration]: EXISTING_INTEGRATION
Using existing API integration 'EXISTING_INTEGRATION'. +------------------------------------------------------+ | status | |------------------------------------------------------| | Git Repository SNOWCLI_GIT was successfully created. | +------------------------------------------------------+
如果在 连接 中指定的角色或用户未被授予,执行此命令将生成类似于以下内容的错误:
003001 (42501): 01b2f095-0508-c66d-0001-c1be009a66ee: SQL access control error: Insufficient privileges to operate on account XXX
在这种情况下,您应检查您的连接配置或请求您的账户管理员授予您必要的权限或为您创建集成。有关更多信息,请参阅 创建用于与存储库 API 进行交互的 API 集成。