# read_git_branch_via_subprocess

> **Function** in `deepagents_cli`

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

Fall back to `git rev-parse` for unusual repository layouts.

## Signature

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

## Parameters

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

## Returns

`str`

The branch name reported by git, or an empty string on failure.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/64d45f67c86edb4df2ced0e7b82f1a8fd158ec8c/libs/cli/deepagents_cli/_git.py#L192)