# read_git_commit_sha_from_filesystem

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/_git/read_git_commit_sha_from_filesystem)

Read the current `HEAD` commit SHA from repository metadata.

Resolves a symbolic `HEAD` (`ref: refs/heads/<branch>`) by reading the
loose ref file, then `packed-refs`. A detached `HEAD` already contains the
raw SHA.

## Signature

```python
read_git_commit_sha_from_filesystem(
    path: str | Path,
) -> str | None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `path` | `str \| Path` | Yes | Directory or file path inside a repository. |

## Returns

`str | None`

The full commit SHA (40-char SHA-1 or 64-char SHA-256), an empty string
when `path` is not inside a git repository, or `None` when metadata
exists but cannot be resolved.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/e14e0adcbe78565ed3650e7f24b2a775d5437d25/libs/code/deepagents_code/_git.py#L246)