Snowflake Git Integration registers a Git repository (GitHub, GitLab, etc.) as a Snowflake database object, letting you directly reference and execute the SQL scripts, Python files, and configuration files it contains from inside Snowflake. It's a great fit for Infrastructure as Code (IaC) and CI/CD pipeline integration, and you can also use it to version-control Snowflake Notebooks.
Step 1: Secret(認証情報)の作成
↓
Step 2: API Integration(Git API接続)の作成
↓
Step 3: Git Repositoryオブジェクトの作成
↓
Step 4: FETCH でリモートと同期
↓
Step 5: ファイル参照・スクリプト実行-- GitHubのPersonal Access Token (PAT) を格納
CREATE OR REPLACE SECRET git_pat_secret
TYPE = PASSWORD
USERNAME = 'github-username'
PASSWORD = 'ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
-- パブリックリポジトリの場合はSecretは不要-- GitHub用のAPI Integration
CREATE OR REPLACE API INTEGRATION github_api_integration
API_PROVIDER = git_https_api
API_ALLOWED_PREFIXES = ('https://github.com/my-org/')
ALLOWED_AUTHENTICATION_SECRETS = (git_pat_secret)
ENABLED = TRUE;-- Git Repositoryオブジェクトの作成
CREATE OR REPLACE GIT REPOSITORY analytics_db.public.my_sql_repo
API_INTEGRATION = github_api_integration
GIT_CREDENTIALS = git_pat_secret
ORIGIN = 'https://github.com/my-org/snowflake-sql-scripts.git';
-- パブリックリポジトリの場合(認証なし)
CREATE OR REPLACE GIT REPOSITORY analytics_db.public.public_repo
API_INTEGRATION = github_api_integration
ORIGIN = 'https://github.com/my-org/public-scripts.git';-- リモートリポジトリの最新を取得
ALTER GIT REPOSITORY analytics_db.public.my_sql_repo FETCH;
-- ブランチ一覧を確認
SHOW GIT BRANCHES IN analytics_db.public.my_sql_repo;
-- タグ一覧を確認
SHOW GIT TAGS IN analytics_db.public.my_sql_repo;-- mainブランチのファイル一覧
LIST @analytics_db.public.my_sql_repo/branches/main/;
-- 特定ディレクトリのファイル一覧
LIST @analytics_db.public.my_sql_repo/branches/main/sql/transforms/;
-- 特定タグのファイル一覧
LIST @analytics_db.public.my_sql_repo/tags/v1.2.0/;
-- ファイルの内容を読み取り
SELECT $1 AS content
FROM @analytics_db.public.my_sql_repo/branches/main/README.md
(FILE_FORMAT => 'util_db.formats.text_raw');-- Git Repository内のSQLスクリプトを直接実行
EXECUTE IMMEDIATE FROM
@analytics_db.public.my_sql_repo/branches/main/sql/create_tables.sql;
-- 特定タグ(バージョン)のスクリプトを実行
EXECUTE IMMEDIATE FROM
@analytics_db.public.my_sql_repo/tags/v1.2.0/sql/migrations/001_add_columns.sql;
-- 変数を渡してスクリプトを実行
EXECUTE IMMEDIATE FROM
@analytics_db.public.my_sql_repo/branches/main/sql/parameterized_query.sql
USING (target_date => '2026-03-27', batch_size => 10000);| Path format | What it references | Example |
|---|---|---|
| @repo/branches/<branch>/ | Latest commit on a branch | @my_repo/branches/main/sql/ |
| @repo/tags/<tag>/ | Commit pinned to a specific tag | @my_repo/tags/v1.0.0/sql/ |
| @repo/commits/<hash>/ | A specific commit hash | @my_repo/commits/abc123/sql/ |
By linking a Snowsight Notebook to a Git repository, the Notebook's versions are managed through Git.
-- TaskでFETCH → スクリプト実行を自動化
CREATE OR REPLACE TASK daily_deploy
WAREHOUSE = ops_wh
SCHEDULE = 'USING CRON 0 6 * * * UTC'
AS
BEGIN
ALTER GIT REPOSITORY my_sql_repo FETCH;
EXECUTE IMMEDIATE FROM
@my_sql_repo/branches/main/sql/daily_etl.sql;
END;
ALTER TASK daily_deploy RESUME;| Operation | Required privilege |
|---|---|
| CREATE GIT REPOSITORY | CREATE GIT REPOSITORY on the schema |
| ALTER GIT REPOSITORY FETCH | OWNERSHIP or MONITOR on the Git Repository |
| EXECUTE IMMEDIATE FROM @repo | READ on the Git Repository plus execute privileges for the SQL inside the script |
| LIST @repo | READ on the Git Repository |
DevOps & Git
問題 1
You want to register a private GitHub repository as a Snowflake Git Repository. Which combination of objects must be created before running CREATE GIT REPOSITORY?
正解: B
Connecting to a private Git repository requires two objects: (1) a Secret (TYPE = PASSWORD) that stores the Personal Access Token, and (2) an API Integration with API_PROVIDER = git_https_api. CREATE GIT REPOSITORY then references the Secret in GIT_CREDENTIALS and the API Integration in API_INTEGRATION. Storage Integration is for Stages, and Network Rule is for External Access Integration — neither is used for Git Integration.
Which Git providers does Snowflake's Git Integration support?
Snowflake supports any Git repository reachable over HTTPS, including GitHub, GitLab, Bitbucket, and Azure DevOps Repos. The SSH protocol is not supported, so you must register repositories using their HTTPS URLs. For private repositories, authenticate by storing a Personal Access Token (PAT) in a Secret object.
Is the content of a registered Git Repository synced in real time?
No, the sync is not automatic. You must run ALTER GIT REPOSITORY ... FETCH manually or schedule it with a Task to pull the latest content from the remote. Once fetched, you can access files on specific branches or tags via SQL queries. FETCH operations are billed in Serverless Credits.
Can I use files inside a Git Repository as a source for COPY INTO?
Not directly. A Git Repository is intended for managing code and scripts, not for bulk data loading the way a Stage is. However, you can drive data pipelines indirectly by executing SQL scripts stored in the repository, for example EXECUTE IMMEDIATE FROM @git_repo/branches/main/scripts/load.sql.
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Snowflake Certifications: All 11 Exams Explained (2026)
Every SnowPro certification — Associate, Core, Specialty, Ad...
Snowflake Exam Difficulty Ranking: All 11 Certs Compared (2026)
All 11 SnowPro exams ranked by difficulty with study-time es...
Snowflake Study Guide: Fastest Pass Route by Exam (2026)
How to pass SnowPro certifications efficiently — official ma...
SnowPro Core (COF-C03): Complete Exam Guide (2026)
Pass the SnowPro Core exam — six domains, scope, sample ques...
SnowPro Associate Platform (SOL-C01): Complete Guide (2026)
The entry-level SnowPro Associate exam — scope, weighting, s...