Restore a config file from git history
git_git_rollback_fileRestore a single file to its state at a specific commit to undo accidental edits. Requires confirmation; only affects that file, not the entire config tree.
Instructions
Restore one file to its state at a specific commit.
Refuses a relative_path that resolves outside /config
(_resolve_within_config) before running anything, and without
confirm=True returns a safety prompt instead of touching the file;
with confirm=True it calls repo.git.checkout(sha, '--', relative_path), replacing the file's on-disk content with the version
from sha and losing any uncommitted changes to that file.
Use when: undoing an accidental edit to a single file.
Not for: resetting the whole config tree — use
git_git_rollback_to_commit.
Returns: dict {"status": "restored", "file", "to"} on success.
Errors: returns {"error": "invalid_path"|"path_outside_config", ...}
when relative_path escapes /config; returns {"error": "confirmation_required", ...} when confirm is not True; raises
RuntimeError (from _repo()) when no git repo exists.
Limits: requires confirm=True; uncommitted changes to the target
file are permanently lost once it runs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sha | No | Commit SHA or ref to restore the file from. Defaults to 'HEAD', which discards uncommitted changes to this file. | HEAD |
| confirm | No | Must be True to actually restore the file. False (default) returns a safety prompt describing what would happen instead of touching anything. | |
| relative_path | Yes | Path to the file relative to the HA config directory to restore, e.g. 'automations.yaml'. Must resolve inside /config after following symlinks. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||