Skip to content

CLI Reference

Complete reference for the Copybara command-line interface.

Terminal window
java -jar copybara_deploy.jar <command> <config_file> [workflow] [source_ref] [flags]

Copybara supports the following commands:

CommandDescription
migrateExecute a migration workflow (default)
validateValidate configuration without running
infoShow migration state and pending changes
feedbackRun a feedback workflow
helpShow help for commands and flags
versionShow Copybara version
generatorGenerate a config file interactively
onboardExperimental assisted onboarding tool
regenerateRegenerate patch files

The primary command for running synchronization workflows:

Terminal window
copybara migrate copy.bara.sky workflow_name [source_ref] [flags]

Arguments:

  • config_file: Path to your .bara.sky configuration file
  • workflow_name: Name of the workflow to run (defaults to default)
  • source_ref: Optional reference to migrate from (usually auto-detected)

Example:

Terminal window
copybara migrate copy.bara.sky export --init-history

Validate configuration syntax and structure without executing:

Terminal window
copybara validate copy.bara.sky [workflow_name]

Example:

Terminal window
copybara validate copy.bara.sky export

Show information about the migration state:

Terminal window
copybara info copy.bara.sky workflow_name

Shows the last migrated revision and pending changes.

Run a feedback workflow (for event-driven actions):

Terminal window
copybara feedback copy.bara.sky feedback_workflow_name

Show help for any command:

Terminal window
copybara help # General help
copybara help migrate # Help for migrate command

Show the installed Copybara version:

Terminal window
copybara version

Interactively generate a configuration file:

Terminal window
copybara generator

Process all history from the beginning. Required for first-time sync:

Terminal window
copybara migrate copy.bara.sky export --init-history

Start from a specific commit SHA:

Terminal window
copybara migrate copy.bara.sky export --last-rev abc123def456

Useful for:

  • Resetting state after issues
  • Skipping problematic commits
  • Starting from a known good point

Force sync even if state tracking suggests changes were already migrated:

Terminal window
copybara migrate copy.bara.sky export --force

Don’t fail if there are no changes to migrate (exit code 0 instead of 2):

Terminal window
copybara migrate copy.bara.sky export --ignore-noop

Recommended for CI/CD where “no changes” is not an error.

Preview what would happen without making actual changes:

Terminal window
copybara migrate copy.bara.sky export --dry-run

Some destinations may still create draft PRs in dry-run mode.

Override workflow mode to SQUASH for this run:

Terminal window
copybara migrate copy.bara.sky export --squash

Useful for one-off squashed exports from ITERATIVE workflows.


These flags help you test workflows locally without pushing to real destinations.

Write output to a local directory instead of the configured destination:

Terminal window
copybara migrate copy.bara.sky export --folder-dir /tmp/output

Note: The directory will be cleared before writing. All existing files are deleted.

Force any workflow to use folder.destination() without modifying the config:

Terminal window
copybara migrate copy.bara.sky export --to-folder

Combined with --folder-dir:

Terminal window
copybara migrate copy.bara.sky export --to-folder --folder-dir /tmp/preview

This is perfect for testing what a real workflow would produce.


Override Git-related settings from the command line.

Override the destination repository URL:

Terminal window
copybara migrate copy.bara.sky export \
--git-destination-url https://github.com/other/repo

Override the destination branch to push to:

Terminal window
copybara migrate copy.bara.sky export \
--git-destination-push feature-branch

Override the destination branch to fetch from:

Terminal window
copybara migrate copy.bara.sky export \
--git-destination-fetch main

Override the default commit author:

Terminal window
copybara migrate copy.bara.sky export \
--default-author "Bot <bot@example.com>"

Reuse a specific Gerrit change ID:

Terminal window
copybara migrate copy.bara.sky export \
--gerrit-change-id I1234567890abcdef

Set the Gerrit topic for the change:

Terminal window
copybara migrate copy.bara.sky export \
--gerrit-topic my-feature

Override the PR branch name:

Terminal window
copybara migrate copy.bara.sky export \
--github-destination-pr-branch custom-branch-name

Read the config from the change being migrated (for versioned configs):

Terminal window
copybara migrate copy.bara.sky export --read-config-from-change

Limit the number of changes to process in ITERATIVE mode:

Terminal window
copybara migrate copy.bara.sky export --iterative-limit-changes 10

Re-import the same version that was last imported:

Terminal window
copybara migrate copy.bara.sky export --same-version

Useful for verifying config refactors don’t change output.

Set the root path for resolving absolute config labels:

Terminal window
copybara migrate copy.bara.sky export \
--config-root /path/to/configs

Write console output to a file:

Terminal window
copybara migrate copy.bara.sky export \
--console-file-path copybara.log

Increase output verbosity:

Terminal window
copybara migrate copy.bara.sky export -v # Verbose
copybara migrate copy.bara.sky export -v -v # More verbose

Disable ANSI color codes (useful for CI logs):

Terminal window
copybara migrate copy.bara.sky export --noansi

Set timeout for individual commands (default: 15 minutes):

Terminal window
copybara migrate copy.bara.sky export --commands-timeout PT30M

Format uses ISO 8601 duration (PT = Period Time, M = Minutes, H = Hours).

Set timeout for repository operations (default: 15 minutes):

Terminal window
copybara migrate copy.bara.sky export --repo-timeout PT20M

Number of threads for parallel transformations (default: 10):

Terminal window
copybara migrate copy.bara.sky export --threads 20

Terminal window
copybara migrate copy.bara.sky export --init-history
Terminal window
copybara migrate copy.bara.sky export --ignore-noop
Terminal window
copybara migrate copy.bara.sky export \
--to-folder \
--folder-dir /tmp/preview
Terminal window
copybara migrate copy.bara.sky export \
--last-rev abc123 \
--force
Terminal window
copybara validate copy.bara.sky
Terminal window
copybara migrate copy.bara.sky export \
--to-folder \
--folder-dir /tmp/debug \
-v

CodeMeaning
0Success
1Error (configuration, runtime, or authentication)
2No changes to migrate (use --ignore-noop to suppress)

VariableDescription
COPYBARA_CONFIGDefault configuration file path
GIT_AUTHOR_NAMEOverride Git author name
GIT_AUTHOR_EMAILOverride Git author email
GIT_COMMITTER_NAMEOverride Git committer name
GIT_COMMITTER_EMAILOverride Git committer email