For the complete documentation index, see llms.txt. This page is also available as Markdown.

Code Repository

Use the Harness CLI to manage the Code Repository module, including repositories, pull requests, reviewers, AI review insights, branches, commits, tags, comments, and checks.

Harness Code Repository provides built-in git hosting within the Harness platform. The CLI gives you full access to repository management, pull request workflows, code review, branch operations, and commit history without switching to a browser or external git host. Use these commands to automate code review workflows, manage branches at scale, and integrate repository operations into scripts and pipelines.

This page covers all Code Repository resources and actions available in the CLI.


What you will learn in this topic

By the end of this page, you will know how to:

  • List, create, update, and delete repositories.

  • Open, update, merge, and close pull requests from the terminal.

  • List the pull requests you authored and the pull requests that await your review across every repository in scope.

  • Submit review decisions and manage reviewers and codeowners.

  • Retrieve Harness Code AI review insights, such as risk summaries, suggested reviewers, and suggested labels.

  • View pull request activity, manage comments, and inspect status checks.

  • Create and manage branches and tags.

  • Inspect commit history and individual commit details.


Before you begin

  • Harness CLI installed and authenticated: For setup steps, see Install and upgrade and Authenticate.

  • Project scope configured: Code Repository resources require --org and --project. Set them in your profile or pass them on each command.


Resource identifiers

Repositories are top-level resources. Pull requests, branches, commits, and tags live inside a repository, so they use compound identifiers that combine the repository with the child resource:

  • <repo>/<pr_number>: A pull request in a repository.

  • <repo>/<branch>: A branch in a repository.

  • <repo>/<sha>: A commit in a repository.

  • <repo>/<pr_number>/<reviewer_id>: A reviewer on a pull request.

  • <repo>/<pr_number>/<comment_id>: A comment on a pull request.

Leave the slash in a compound identifier unencoded. For the --set, --del, -f, --format, paging, and scope conventions that apply to every command on this page, see Global flags and output.


Repositories

A repository stores your source code and tracks changes through git. Each repository belongs to a project and has a default branch, description, and access settings. Use repository commands to create new projects, update configurations, or remove archived code.

List repositories

View all repositories in your project to browse available codebases. Repository is a multi-level noun, so it also supports account and organization scope.

Get repository details

Retrieve the full metadata for a repository, including its default branch, size, clone URLs, and creation date.

Create a repository

Create a new empty repository. Only identifier is required. The default_branch, description, and is_public fields are optional.

Update a repository

Modify the description, default_branch, or is_public setting on an existing repository.

Delete a repository

Remove a repository and all its contents, branches, and history. This action is irreversible.


Pull requests

A pull request proposes changes from one branch to another for code review. Pull requests track the discussion, review decisions, and merge status of a set of commits. Use the CLI to manage the entire pull request lifecycle from creation through merge.

List pull requests

View pull requests in a repository. Pass the repository identifier as a positional argument.

List your own pull requests

List the pull requests you authored across every repository in scope. This command does not take a repository identifier.

List pull requests awaiting your review

List the pull requests that await your review across every repository in scope.

Get pull request details

Retrieve the full metadata for a pull request using the <repo_id>/<pr_number> format. The default output is rich text produced by the workflow formatter.

Create a pull request

Open a new pull request from a source branch to a target branch. Pass the repository as a positional argument. To supply the description body from a file, use -f.

Update a pull request

Modify the title, description, draft state, or other editable fields on an existing pull request.

Merge a pull request

Merge an approved pull request into its target branch. Use --method to select the merge strategy, --delete-branch to remove the source branch after the merge, and --dry-run to validate the merge without applying it.

Close a pull request

Close a pull request without merging its changes. Use this to abandon proposals that are no longer relevant.


Reviews, reviewers, and codeowners

A review records a decision on a pull request. Reviewers are the principals asked to review the changes, and codeowners are the reviewers that repository ownership rules assign automatically based on the files a pull request touches.

Submit a review decision

Approve a pull request or request changes on it.

List Code principals

List the Code principals, such as users and service accounts, that are available in scope. Use this to look up the identifier of a reviewer before you add them.

List reviewers

View the reviewers on a pull request, along with each reviewer's decision, type, and the principal who added them.

Add a reviewer

Add a reviewer to a pull request. The CLI resolves the value you pass to --reviewer automatically, so you can use an email address, a UID, or an identifier.

Remove a reviewer

Remove a reviewer from a pull request using the <repo_id>/<pr_number>/<reviewer_id> format.

List codeowners

View the codeowners evaluated on a pull request, including the matched pattern, the owner, and the review decision.


AI review insights

Harness Code AI review analyzes a pull request and produces review guidance: a risk summary, risk-bucketed file groups, suggested reviewers, suggested labels, and success-criteria results. Use these commands to pull that guidance into the terminal or into a script.

Get the risk summary insight

Retrieve the risk summary insight for a pull request.

Get risk-bucketed review groups

Retrieve the risk-bucketed file groups for review. The default output is formatted for terminal display.

List suggested reviewers

List the reviewers that AI review suggests for a pull request.

List suggested labels

List the labels that AI review suggests for a pull request.

List success-criteria results

List the AI review success-criteria results for a pull request.


Pull request activity, comments, and checks

Pull request activity is the complete log of events on a pull request: comments, review decisions, status changes, and commit updates. Comments carry the review discussion, and checks report the status results that pipelines and other integrations publish.

List pull request activity

View the activity timeline for a pull request. Filter the timeline with --kind and --type.

List comments

View the comments on a pull request.

Post a comment

Post a comment on a pull request. Supply the comment body with -f <file> or on stdin. To reply within an existing thread, pass the parent comment identifier to --reply-to.

Update a comment

Edit the text of an existing comment using the <repo_id>/<pr_number>/<comment_id> format.

Delete a comment

Remove a comment from a pull request.

List pull request checks

View the status checks on a pull request. When a check reports them, the output includes the pipeline identifier, the execution identifier, and the stage.

List commit checks

View the status checks on a specific commit SHA.


Branches

A branch is a named pointer to a commit in a repository. Branches let multiple developers work on different features simultaneously without interfering with each other. Use branch commands to create feature branches, inspect branch state, or clean up merged branches.

List branches

View all branches in a repository to see active development work. Pass the repository as a positional argument.

Get branch details

Retrieve metadata for a specific branch using the <repo_id>/<branch_name> format.

Create a branch

Create a new branch from a specified target commit or branch. Pass the repository as a positional argument.

Delete a branch

Remove a branch that has been merged or is no longer needed.


Commits

A commit is an immutable snapshot of repository contents at a point in time. Each commit records who made the change, when, and why (through the commit message). Use commit commands to browse history and inspect individual changes for debugging or auditing.

List recent commits

View the commit history for a repository. Pass the repository as a positional argument. Use --branch to list commits on a specific ref and --path to list commits that touch a specific file.

List commits in a pull request

View only the commits that a pull request contains.

Get commit details

Retrieve the full metadata for a specific commit using the <repo_id>/<sha> format.


Tags

A tag marks a specific commit with a human-readable name, typically used to identify release versions. Unlike branches, tags do not move forward with new commits. Use tags to create stable release markers that you can reference in deployments and changelogs.

List tags

View all tags in a repository to see the release history. Pass the repository as a positional argument.

Create a tag

Create a new tag pointing to a specific commit. Pass the repository as a positional argument.

Delete a tag

Remove a tag that was created in error or is no longer relevant. The underlying commit remains unchanged.


Last updated

Was this helpful?