HeadlinesBriefing favicon HeadlinesBriefing.com

Google's Copybara: Tool for Syncing Code Between Private and Public Repositories

Hacker News •
×

Google has open-sourced Copybara, an internal tool designed to transform and move source code between repositories. The utility addresses a common challenge where projects need to maintain both confidential and public repositories in sync, ensuring one authoritative source while allowing contributions across multiple locations.

Copybara's stateless architecture stores state as labels in commit messages, enabling multiple users or services to work with the same configuration without conflicts. The tool supports Git repositories as its primary backend, with experimental Mercurial read support. An extensible design permits adding custom origins and destinations for various workflows.

Typical applications include importing code sections from private to public repositories, or pulling community contributions back into internal codebases. When changes occur in non-authoritative repositories, Copybara automatically transforms and migrates them to the correct location, handling merge conflicts similarly to out-of-date changes.

Users can install pre-built weekly snapshots or compile from source using JDK 11 and Bazel. Configuration files written in Starlark define workflows with origin and destination repositories, file transformations, and authoring rules. The project includes Docker support and integrates with Bazel build systems for streamlined adoption.