Git Clone
Clone the triggering repository (or any git URL) into the workspace.
Reference: loha/git-clone@v1
Category: source-control
Runtime: alpine/git:2.43.0 (non-root, digest-pinned)
License: Apache-2.0
When to use
Use this step at the start of nearly every pipeline. It checks out source code so later steps have something to build, test, or deploy. For the triggering repo it is auto-injected by Loha; reach for it manually when you need a non-default branch, a second repo, or submodules.
Parameters
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
url | string | — | Yes | Repository URL to clone |
revision | string | main | No | Git revision to checkout (branch, tag, sha) |
depth | string | 1 | No | Shallow clone depth (0 for full clone) |
submodules | string | true | No | Initialize and checkout git submodules |
sslVerify | string | true | No | Enable SSL certificate verification |
subdirectory | string | "" | No | Subdirectory within workspace to clone into |
deleteExisting | string | true | No | Delete existing contents before cloning |
Workspaces
output(required): bound from pipeline workspacesourcessh-directory(optional): bound from pipeline workspacessh-credentialsbasic-auth(optional): bound from pipeline workspacegit-credentials
Results
| Result | Description |
|---|---|
commit | The precise commit SHA that was checked out |
url | The URL of the cloned repository |
committer-date | The epoch timestamp of the commit |
How it works
Runs plain git from the alpine/git image. Defaults to a depth-1 shallow clone for speed; set depth: "0" for a full history (needed for git describe, monorepo change detection, etc.). Authentication is provided by mounting either an SSH key (ssh-directory workspace) or basic-auth credentials (basic-auth workspace); both are optional and only needed for private repos.
Examples
Clone the triggering repository
The simplest case: clone whatever repo triggered the pipeline. Loha injects the URL and revision automatically.
steps:
- name: checkout
uses: loha/git-clone@v1
with:
url: '${REPO_URL}'
revision: '${COMMIT_SHA}'
Full history with submodules
When you need the whole git log (for monorepo affected-detection, semver via git describe, etc.) and submodules.
steps:
- name: checkout
uses: loha/git-clone@v1
with:
url: 'https://github.com/my-org/my-monorepo'
revision: 'main'
depth: '0'
submodules: 'true'
Troubleshooting
Problem: Authentication failed cloning a private repository.
Solution: Wire up the ssh-directory or basic-auth workspace; both are optional and unmounted by default. The portal exposes a "Repository credentials" section where this is configured.
Problem: git describe returns "fatal: No tags found".
Solution: Set depth: "0" for a full clone; the default shallow clone strips tag history.