Google copybara: moving code between repositories

254 points · 49 comments on HN · read original →

Points and comments are a snapshot, not live.

Copybara transforms and moves code between repositories, supporting stateless synchronization with Git as the primary type.

Copybara allows repetitive or one-time code movement between repositories, designating one as authoritative but enabling contributions to any and releases from any. It stores state in destination commit labels, making it stateless. Currently supports Git and experimental Mercurial. Users can get started with weekly snapshot releases or build from source with JDK 11 and Bazel. Docker use is experimental. It includes features like path remapping and commit author alteration.

What commenters are saying

Commenters widely see Copybara as useful for syncing internal monorepos with public repositories, particularly for exporting code with transformations. Several note Google uses it one-way from monorepo to GitHub, with external contributions handled via manual or semi-automated patch replication. Downsides include slow performance on many commits unless using local repos, and that history preservation rewrites SHAs (original SHA embedded in commit trailer). Some mention alternatives like Josh (used by Rust) and git subtree, though subtree has poor performance on large repos. A minority express concern about potential abuse for malware bait repos.