Git

Built-in step · 4 steps

Clone a repository, commit changes to it, and push to or pull from GitHub, GitLab, Bitbucket or any Git server.

Steps

StepWhat it does
Clone a repositoryFetch a Git repository from GitHub, GitLab, Bitbucket, Azure DevOps or your own server, so the steps after this one can commit to it, push it and pull it.
Commit changesWrite files into a cloned repository and record the changes as a commit with a message.
Pull changesBring the latest commits from the repository's host into the cloned repository, so the workflow works from, and commits on top of, what is there now.
Push changesSend the commits made in this workflow to the repository's host, so they show up on GitHub, GitLab or wherever it lives.

Clone a repository

Fetch a Git repository from GitHub, GitLab, Bitbucket, Azure DevOps or your own server, so the steps after this one can commit to it, push it and pull it. The repository is kept for this run; pass this step's result to those steps. A private repository needs a token (https) or an SSH key (ssh), stored as a workspace secret.

Inputs

Repository addressurltextRequired
The repository's address, as its host shows it under Clone: https://github.com/acme/website.git, or for ssh git@github.com:acme/website.git.
Branchbranchtext
The branch to start on. Leave empty for the repository's default branch.
History depthdepthnumber
How many commits of history to fetch. Leave empty for all of it; 1 is fastest when the workflow only needs the latest files, and still lets it commit and push.At least 1.
Usernameusernametext
For an https address with a token: the name to send with it. GitHub, GitLab and Azure DevOps take any name, so it can be left empty; Bitbucket needs your username with an app password, or x-token-auth with an access token.
Password or tokenpasswordtext
For an https address: the token or password that may read it, such as a GitHub personal access token. Store it as a workspace secret and put @secrets.GITHUB_TOKEN here, so it is never kept in the workflow. A public repository needs none to clone or pull.
SSH private keyssh_private_keytext
For an ssh address (git@github.com:acme/website.git): the private key whose public half is added to the repository or the account. Store the whole key, from BEGIN to END, as a workspace secret and reference it here.

Outputs

The cloned repository: 'repository' is what the Commit, Push and Pull steps take, with the branch it is on, its latest commit and message, and its files.

branchtext
The branch it is on, or null when it was cloned at a tag.
committext
The latest commit's id, or null for an empty repository.
file_countnumber
How many files the repository has on this branch.
fileslist
The paths of the repository's files on this branch, up to the first thousand.
messagetext
The latest commit's message.
repositorytext
The repository, for the Commit, Push and Pull steps' Repository field.
urltext
The address it was cloned from.
Example output
{
  "branch": "main",
  "commit": "9fceb02d0ae598e95dc970b74767f19372d61af8",
  "file_count": 3,
  "files": [
    "README.md",
    "prices/autumn.csv",
    "src/index.html"
  ],
  "message": "Update the autumn price list",
  "repository": "3f2a9c1e5b7d4e8fa0c6b2d1e9f73a54",
  "url": "https://github.com/acme/website.git"
}

Commit changes

Write files into a cloned repository and record the changes as a commit with a message. A file's content can be text, data from earlier steps (saved as JSON), or a file an earlier step made or downloaded. Nothing reaches the host until a Push changes step.

Inputs

RepositoryrepositorytextRequired
The repository from a Clone a repository step earlier in this workflow: pick that step's result, such as @cloned.
MessagemessagetextRequired
What the commit changes, such as 'Update the autumn price list'.
Files to writefilesobject
Each file's path in the repository and what to put in it: text as it is, a list or record as JSON, or a file from an earlier step (its doc_ id). A file that isn't there yet is created, folders and all.
Files to deletedeletelist
Paths of files or folders to remove from the repository.
Changes to includepathslist
Leave empty to commit every change in the repository. Otherwise, only changes under these paths are committed.
Branchbranchtext
The branch to commit on. Leave empty for the branch the repository is on; a branch that doesn't exist yet is created, which is how a workflow prepares a pull request.
Author nameauthor_nametext
Who the commit is by. Lodol when left empty.
Author emailauthor_emailtext
The author's email address, which hosts use to link the commit to an account.

Outputs

The commit made: its id and the files it changed. When the files were already as written, 'committed' is false and there is no commit.

branchtext
The branch the commit is on.
committext
The new commit's id.
committedtrue/false
Whether there was anything to commit.
files_changedlist
The paths the commit changed.
messagetext
The message.
repositorytext
The repository, for the steps after this one.
short_committext
The first seven characters of the id.
Example output
{
  "branch": "main",
  "commit": "a1b2c3d4e5f60718293a4b5c6d7e8f9012345678",
  "committed": true,
  "files_changed": [
    "prices/winter.csv"
  ],
  "message": "Update the winter price list",
  "repository": "3f2a9c1e5b7d4e8fa0c6b2d1e9f73a54",
  "short_commit": "a1b2c3d"
}

Pull changes

Bring the latest commits from the repository's host into the cloned repository, so the workflow works from, and commits on top of, what is there now.

Inputs

RepositoryrepositorytextRequired
The repository from a Clone a repository step earlier in this workflow: pick that step's result, such as @cloned.
Branchbranchtext
The branch to pull. Leave empty for the branch the repository is on.
Usernameusernametext
For an https address with a token: the name to send with it. GitHub, GitLab and Azure DevOps take any name, so it can be left empty; Bitbucket needs your username with an app password, or x-token-auth with an access token.
Password or tokenpasswordtext
For an https address: the token or password that may read it, such as a GitHub personal access token. Store it as a workspace secret and put @secrets.GITHUB_TOKEN here, so it is never kept in the workflow. A public repository needs none to clone or pull.
SSH private keyssh_private_keytext
For an ssh address (git@github.com:acme/website.git): the private key whose public half is added to the repository or the account. Store the whole key, from BEGIN to END, as a workspace secret and reference it here.

Outputs

The branch after the pull: its latest commit, whether anything came in ('updated'), which files changed, and the repository's files now.

branchtext
The branch pulled.
committext
The latest commit's id after the pull.
file_countnumber
How many files the repository has on this branch.
fileslist
The paths of the repository's files on this branch, up to the first thousand.
files_changedlist
The paths the pull changed.
messagetext
The latest commit's message.
previous_committext
The latest commit's id before it.
repositorytext
The repository, for the steps after this one.
updatedtrue/false
Whether new commits came in.
Example output
{
  "branch": "main",
  "commit": "c0ffee1234567890abcdef1234567890abcdef12",
  "file_count": 4,
  "files": [
    "README.md",
    "prices/autumn.csv",
    "src/index.html",
    "src/spring.html"
  ],
  "files_changed": [
    "src/index.html",
    "src/spring.html"
  ],
  "message": "Add the spring collection",
  "previous_commit": "9fceb02d0ae598e95dc970b74767f19372d61af8",
  "repository": "3f2a9c1e5b7d4e8fa0c6b2d1e9f73a54",
  "updated": true
}

Push changes

Send the commits made in this workflow to the repository's host, so they show up on GitHub, GitLab or wherever it lives. Pushing needs a token or key with write access.

Inputs

RepositoryrepositorytextRequired
The repository from a Clone a repository step earlier in this workflow: pick that step's result, such as @cloned.
Branchbranchtext
The branch to push. Leave empty for the branch the repository is on.
Push toremotetext
Leave empty to push back to where the repository was cloned from, or give another repository's address to push there instead.
Force pushforcetrue/false
Replace the branch on the host even when it has commits this copy doesn't. Off, a push behind the host is refused, which is the safe default.Default: false.
Usernameusernametext
For an https address with a token: the name to send with it. GitHub, GitLab and Azure DevOps take any name, so it can be left empty; Bitbucket needs your username with an app password, or x-token-auth with an access token.
Password or tokenpasswordtext
For an https address: the token or password that may push to it, such as a GitHub personal access token. Store it as a workspace secret and put @secrets.GITHUB_TOKEN here, so it is never kept in the workflow. A public repository needs none to clone or pull.
SSH private keyssh_private_keytext
For an ssh address (git@github.com:acme/website.git): the private key whose public half is added to the repository or the account. Store the whole key, from BEGIN to END, as a workspace secret and reference it here.

Outputs

What was pushed: the branch, the commit it is now at on the host, and whether anything moved ('pushed'), or the host already had it all ('up_to_date').

branchtext
The branch pushed.
committext
The commit the branch is now at.
pushedtrue/false
Whether the host received new commits.
remotetext
The address pushed to.
repositorytext
The repository, for the steps after this one.
summarytext
Git's own summary of the push, such as 9fceb02..a1b2c3d or [new branch].
up_to_datetrue/false
Whether the host already had them all.
Example output
{
  "branch": "main",
  "commit": "a1b2c3d4e5f60718293a4b5c6d7e8f9012345678",
  "pushed": true,
  "remote": "https://github.com/acme/website.git",
  "repository": "3f2a9c1e5b7d4e8fa0c6b2d1e9f73a54",
  "summary": "9fceb02..a1b2c3d",
  "up_to_date": false
}

On this page