Skip to main content

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​

ParameterTypeDefaultRequiredDescription
urlstring—YesRepository URL to clone
revisionstringmainNoGit revision to checkout (branch, tag, sha)
depthstring1NoShallow clone depth (0 for full clone)
submodulesstringtrueNoInitialize and checkout git submodules
sslVerifystringtrueNoEnable SSL certificate verification
subdirectorystring""NoSubdirectory within workspace to clone into
deleteExistingstringtrueNoDelete existing contents before cloning

Workspaces​

  • output (required): bound from pipeline workspace source
  • ssh-directory (optional): bound from pipeline workspace ssh-credentials
  • basic-auth (optional): bound from pipeline workspace git-credentials

Results​

ResultDescription
commitThe precise commit SHA that was checked out
urlThe URL of the cloned repository
committer-dateThe 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.