{"id":24296593,"url":"https://github.com/tdambrin/sf_git","last_synced_at":"2025-09-25T21:31:38.201Z","repository":{"id":216417291,"uuid":"741292382","full_name":"tdambrin/sf_git","owner":"tdambrin","description":"Python-based CLI for Snowflake worksheets Git versioning","archived":false,"fork":false,"pushed_at":"2024-05-15T04:31:21.000Z","size":420,"stargazers_count":14,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-15T21:06:35.999Z","etag":null,"topics":["cli","git","python","snowflake","versioning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tdambrin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-10T04:59:46.000Z","updated_at":"2024-05-29T23:34:29.364Z","dependencies_parsed_at":"2024-05-15T19:22:59.529Z","dependency_job_id":"03c9a408-9c4f-4aef-ab1b-aeb97edb1e89","html_url":"https://github.com/tdambrin/sf_git","commit_stats":null,"previous_names":["tdambrin/sf_git"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdambrin%2Fsf_git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdambrin%2Fsf_git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdambrin%2Fsf_git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tdambrin%2Fsf_git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tdambrin","download_url":"https://codeload.github.com/tdambrin/sf_git/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234258379,"owners_count":18804069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","git","python","snowflake","versioning"],"created_at":"2025-01-16T19:24:47.949Z","updated_at":"2025-09-25T21:31:37.839Z","avatar_url":"https://github.com/tdambrin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/tdambrin/sf_git/assets/61944454/077aa882-95c2-4f61-a05d-64e8e156b266\" alt=\"sfgit logo\" width=\"30%\"\u003e\n\u003c/p\u003e\n\n![image](https://img.shields.io/badge/Python-FFD43B?style=for-the-badge\u0026logo=python\u0026logoColor=blue)\n[![image](https://img.shields.io/badge/Gmail-D14836?style=for-the-badge\u0026logo=gmail\u0026logoColor=white)](mailto:thomas.dambrin@gmail.com?subject=[GitHub]%20Snowflake%20Git%20Versioning)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/tdambrin/e2c293d7db07bee70d2845387cb133ff/raw/sf_git_main_cov_badge.json)\n\n\n\n# Snowflake Git\n\n🆕 Git now supported in Snowflake, see the [official documentation](https://docs.snowflake.com/en/developer-guide/git/git-overview).\n\n# Worksheet Versioning\n\nInspired by a snowflake developers maintained [repository](https://github.com/Snowflake-Labs/sfsnowsightextensions).\n\n### Git integration \n\nThe extension is designed to **apply git versioning on worksheets while developing on Snowsight, fully taking advantage of its functionalities**.\\\nThe following workflow is advised :\n1. [Start session] Upload worksheet from local branch to a user Snowsight workspace\n2. Test, update and validate on Snowsight \n3. [End session] Update local branch with modified Snowsight worksheets\n\n## Install\n\nEntry points are accessible through a CLI once the package is installed. \nTo install it, please follow the following steps :\n\n```bash\n# [Optional: Python virtual environement]\n$ pyenv virtualenv 3.10.4 sf\n$ pyenv activate sf\n\n# [Mandatory: Pip install]\n$ pip install -U pip\n$ pip install sf_git==1.4.2\n\n# [Check your installation]\n$ sfgit --version\n# [Should result in:]\n# sfgit, version 1.4.2\n\n\n# [Check your installation]\n$ sfgit --help\n\n# [Should result in:]\n# Usage: sfgit [OPTIONS] COMMAND [ARGS]...\n# \n# Options:\n#   --help  Show this message and exit.\n# \n# Commands:\n#   commit  Commit Snowsight worksheets to Git repository.\n#   config  Configure sfgit for easier version control.\n#   fetch   Fetch worksheets from user Snowsight account and store them in...\n#   init    Initialize a git repository and set it as the sfgit versioning...\n#   push    Upload locally stored worksheets to Snowsight user workspace.\n```\n\nCommands have been created to **import/export (respectively fetch/push) snowsight worksheets to/from local**.\n\n## Configure your git\n\n\u003e **Warning**\n\u003e A git repository is necessary to manage worksheets. You can either use an existing one\n\u003e or create a new one.\n\nTo apply versioning to your worksheets, you need to **configure Git information**\nthrough the config command. \n\nFirst, set git repository to be used:\n\n```bash\n# if you want to use an existing git repository\n$ sfgit config --git-repo \u003cpath_to_git_repo\u003e\n\n# if you want to create a new one \n$ sfgit init -p \u003cpath_to_git_repo\u003e\n```\n\nThen, set a location to save your worksheets within this git repository:\n```bash\n$ sfgit config --save-dir \u003cpath_to_worksheets_persistency_directory\u003e\n```\n\n## Authenticate\nCurrently, only authentication mode supported is the credentials (PWD) mode.\n\n\u003e :warning: The single sign-on (SSO) will be fixed.\n\nCommands requiring Snowsight authentication all have options to provide at command time. \nIf you don't want to manually input them everytime, you can set them at Python/Virtual environement level with :\n\n\n```bash\n$ sfgit config --account \u003cyour_snowsight_account_id\u003e\n$ sfgit config --username \u003cyour_snowsight_login_name\u003e\n$ sfgit config --password \u003cyour_snowsight_password\u003e  # unnecessary for SSO authentication mode\n```\n\n### Account ID\n\n\u003e [!WARNING]  \n\u003e `The account ID to be configured is in the \u003caccount_name\u003e.\u003cregion\u003e.\u003ccloud\u003e format.`\n\nIf you are unsure about how to retrieve it for your snowflake account, you can run this query:\n\n```sql\nSHOW REGIONS;\n\nWITH \n    SF_REGIONS AS (SELECT * FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()))),\n    INFOS AS (SELECT CURRENT_REGION() AS CR, CURRENT_ACCOUNT() AS CA)\nSELECT CONCAT(\n        LOWER(INFOS.CA),\n        '.',\n        SF_REGIONS.\"region\",\n        '.',\n        SF_REGIONS.\"cloud\"\n    ) AS account_id\nFROM INFOS LEFT JOIN SF_REGIONS ON INFOS.CR = SF_REGIONS.\"snowflake_region\";\n\n```\n\nUnfortunately, the _region_ is not always the same in the _SHOW REGIONS_ ouput. Please check and adapt the format comforming to the official [documentation](https://docs.snowflake.com/en/user-guide/admin-account-identifier#non-vps-account-locator-formats-by-cloud-platform-and-region).\nFor example, eastus2 for Azure should actually be east-us-2.\n\n\n## Use\n\n**Import user worksheet locally** :\n```bash\n$ sfgit fetch --auth-mode PWD\n```\n\n**Import user worksheet locally (using command time args)** :\n```bash\n$ sfgit fetch --username tdambrin --account-id my_account.west-europe.azure -p mysecret -am PWD\n```\n\n**See what changed for only your worksheets in the git** :\n```bash\n$ sfgit diff\n```\n\n**Commit you worksheets** (or through git commands for more flexibility) :\n```bash\n$ sfgit commit --branch master -m \"Initial worksheet commit\"\n```\n\n**Export user worksheets to Snowsight** \n```bash\n$ sfgit push --auth-mode PWD --branch master\n```\n\n## Be creative\n\nUse the package to fit your use case, versioning is a way to do many things.\n\n### Switch versions\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"./doc/images/switch_versions.png\" alt=\"Switch versions\" width=\"70%\"/\u003e\n\u003c/div\u003e\n\n\n### Transfer worksheets to another account\n\n![Transfer accounts](./doc/images/transfer_accounts.png)\n\n## Policies\nFeedbacks and contributions are greatly appreciated. This package was made to ease every day life for Snowflake \ndevelopers and promote version control as much as possible.\n\nFor questions, please feel free to reach out [by email](mailto:thomas.dambrin@gmail.com?subject=[GitHub]%20Snowflake%20Git%20Versioning).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdambrin%2Fsf_git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftdambrin%2Fsf_git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftdambrin%2Fsf_git/lists"}