Skip to content

Tip: Using the GitHub CLI to Copy Labels Between Repositories

Tip

If you manage multiple GitHub repositories and want consistent labels, drift happens quickly.

Use GitHub CLI to run gh label clone and copy a source repository's labels into a destination repository.

If gh is not installed yet, install it first:

brew install gh
sudo apt update && sudo apt install -y gh
# RHEL
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install -y gh

# Fedora
sudo dnf install -y gh
winget install GitHub.cli

Then authenticate:

gh auth login
gh auth status

That second command is worth running. It confirms that your session is active before you try to modify repository settings.

Clone Labels into the Current Repository

If you are already in the destination repository directory, the command is simple:

gh label clone OWNER/SOURCE-REPO

Example:

gh label clone tenthirtyam/example

That copies every label from tenthirtyam/example into the current repository.

Target a Different Destination Repository

If you are not inside the destination repository, use --repo:

gh label clone OWNER/SOURCE-REPO --repo OWNER/DESTINATION-REPO

Example:

gh label clone tenthirtyam/source-example --repo tenthirtyam/destination-example

This is the version I use most often. It is explicit, and explicit is better when you are changing repository metadata.

Overwrite Existing Labels

By default, labels that already exist in the destination repository are skipped. If you want the source repository's label definitions (color and description) to win, add --force:

gh label clone OWNER/SOURCE-REPO --repo OWNER/DESTINATION-REPO --force

Example:

gh label clone tenthirtyam/source-example --repo tenthirtyam/destination-example --force

What the Command Does Not Do

gh label clone is usefully conservative:

  • It copies all labels from the source repository to the destination repository.
  • It skips labels that already exist unless you use --force.
  • It does not delete destination labels that are missing from the source repository.

That last point matters. This is a clone-and-merge operation, not a destructive sync.

When to Use It

This command is especially useful when:

  • You are standardizing labels across an organization.
  • You created a new repository and want the same triage taxonomy as an existing one.
  • You cleaned up one repository's labels and want to reuse that set elsewhere.

Enjoy!

References