git_init_repository
git_init_repository ensures an empty Git repository exists at a project-relative destination. It registers a root task, shows initialization progress in the run UI, and returns a dependency. Repeated calls do nothing when repository mode, object format, and requested initial branch are compatible.
The function never empties an existing directory or repository. It fails when destination contains non-repository files, repository has a commit, or existing repository is incompatible.
Arguments
| Argument | Required | Description |
|---|---|---|
destination | Yes | Project-relative repository directory. |
bare | No | Create or require a bare repository. Defaults to False. |
initial_branch | No | Initial branch short name. Defaults to host global init.defaultBranch, then master. When omitted, any initial branch in an existing compatible empty repository is accepted. |
object_format | No | Object ID format: sha1 or sha256. Defaults to sha256. Set sha1 explicitly for compatibility with hosts that do not support SHA-256 repositories. |
Example
load("@git@1", "git_init_repository")
git_init_repository(
destination=".xx/repositories/output.git",
bare=True,
initial_branch="main",
object_format="sha256",
)