{"id":3800,"library":"scmrepo","title":"scmrepo","description":"scmrepo is an SCM wrapper and fsspec filesystem for Git, commonly used within the DVC ecosystem. It provides a unified API for interacting with Git repositories using various backends like pygit2, dulwich, and gitpython, without necessarily requiring a full `git checkout`. The library is actively maintained, with frequent patch and minor releases.","status":"active","version":"3.6.2","language":"en","source_language":"en","source_url":"https://github.com/treeverse/scmrepo","tags":["git","scm","version control","fsspec","dulwich","pygit2","gitpython"],"install":[{"cmd":"pip install scmrepo","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Provides the core GitFileSystem functionality for abstracting Git repositories as a filesystem.","package":"fsspec"},{"reason":"Optional backend for Git repository operations, a pure-Python implementation.","package":"dulwich","optional":true},{"reason":"Optional backend for Git repository operations, a C-bindings based implementation.","package":"pygit2","optional":true},{"reason":"Optional backend for Git repository operations.","package":"gitpython","optional":true}],"imports":[{"symbol":"GitFileSystem","correct":"from scmrepo.fs import GitFileSystem"},{"symbol":"Git","correct":"from scmrepo.git import Git"}],"quickstart":{"code":"import os\nimport shutil\nimport tempfile\nfrom scmrepo.git import Git\nfrom scmrepo.fs import GitFileSystem\n\n# Create a temporary directory for the repository\nrepo_dir = tempfile.mkdtemp()\nfile_path = os.path.join(repo_dir, \"test_file.txt\")\n\ntry:\n    # Initialize a Git repository\n    git = Git(repo_dir)\n    git.init()\n\n    # Create and commit a file\n    with open(file_path, \"w\") as f:\n        f.write(\"Hello, scmrepo!\\n\")\n    git.add(file_path)\n    git.commit(\"Initial commit\", allow_empty=True)\n\n    # Use GitFileSystem to read the file from 'HEAD'\n    fs = GitFileSystem(repo_dir, rev=\"HEAD\")\n    with fs.open(\"test_file.txt\", \"r\") as f:\n        content = f.read()\n    print(f\"Content of test_file.txt: {content.strip()}\")\n\n    # Demonstrate walking the file system\n    print(\"\\nFiles in repo (from GitFileSystem):\")\n    for root, dnames, fnames in fs.walk(\"/\"):\n        for dname in dnames:\n            print(fs.path.join(root, dname))\n        for fname in fnames:\n            print(fs.path.join(root, fname))\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    # Clean up the temporary directory\n    shutil.rmtree(repo_dir)\n    print(f\"Cleaned up temporary repository at {repo_dir}\")","lang":"python","description":"This quickstart demonstrates how to initialize a Git repository using `scmrepo.git.Git`, commit a file, and then access that file system through `scmrepo.fs.GitFileSystem`."},"warnings":[{"fix":"Install the desired backend package: `pip install scmrepo dulwich` or `pip install scmrepo pygit2`.","message":"scmrepo supports multiple Git backends (dulwich, pygit2, gitpython). To use a specific backend, you must install its corresponding Python package (e.g., `pip install dulwich`) alongside `scmrepo`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update `pygit2` backend code to use `list_heads` and access `LsRemoteResult` attributes directly instead of treating it as a dictionary.","message":"For the `pygit2` backend, the `ls_remotes` method was migrated to `list_heads`, and treating `LsRemoteResult` as a dictionary was deprecated.","severity":"breaking","affected_versions":">=3.5.5"},{"fix":"Ensure `dulwich` is at least version `0.24.3` and update code to use `worktree` for affected operations. Additionally, path handling on Windows with `dulwich>=0.25.1` was fixed in `scmrepo 3.6.2`.","message":"For the `dulwich` backend, `repo stage` was deprecated in favor of `worktree` for some operations, and the minimum `dulwich` version was bumped to `0.24.3`.","severity":"breaking","affected_versions":">=3.5.4"},{"fix":"Upgrade to `scmrepo>=3.5.8` for improved GPG signing compatibility with `dulwich`.","message":"The `dulwich` backend has seen fixes related to GPG signing for commits across several versions. If you encounter issues with signed commits using `dulwich`, check `scmrepo` versions `3.5.7` and `3.5.8` for relevant fixes.","severity":"gotcha","affected_versions":"3.5.0 - 3.5.6"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}