News for hackers. Stuff that matters.
Re:Google copybara: moving code between repositories by namanyayg on Tuesday June 30, 2026 @08:31PM (#48741037)
Nice, I built something similar ~5 years ago using nested git repos and scripts to accomplish a similar purpose of combined private and public repos.

My shell script definitely wasn't google scale tho!

Re:Google copybara: moving code between repositories by UnfitFootprint on Tuesday June 30, 2026 @09:09PM (#48741283)
Yep, same. I thought it might a wrapper around git subtree but looks like it’s doing quite a lot more!

For example altering commit author emails during sync

Re:Google copybara: moving code between repositories by lysace on Tuesday June 30, 2026 @08:42PM (#48741109)
Cute name. (Naming is hard and important.)
Re:Google copybara: moving code between repositories by whh on Tuesday June 30, 2026 @08:45PM (#48741130)
That tune is in my head again... again...
Re:Google copybara: moving code between repositories by MarkSweep on Tuesday June 30, 2026 @09:16PM (#48741324)
Some other interesting tools in the space. Rust is using a tool called Josh to sync commits:

https://josh-project.dev

The blog post from the Rust people:

https://blog.rust-lang.org/inside-rust/2026/06/04/how-josh-h...

Meta used to have an open source tool called fbshipit. But according to its open source repo they no longer use it:

https://github.com/facebookarchive/fbshipit

Any others in this space?

Re:Google copybara: moving code between repositories by wasting_time on Wednesday July 01, 2026 @03:09AM (#48743238)
Re:Google copybara: moving code between repositories by vlovich123 on Wednesday July 01, 2026 @04:06AM (#48743609)
The rust blog post covers this. Subtree performance is terrible on larger repos and they didn’t land something that would fix it on medium sized ones. That’s why they went with a better maintained solution that scales.
Re:Google copybara: moving code between repositories by IshKebab on Wednesday July 01, 2026 @05:48AM (#48744396)
Plus Josh seems to do waaay more - dynamically exposing monorepo directories as a separate repo.

I wish all the effort into things like JJ and Pijul was going into solving those sorts of things instead!

Re:Google copybara: moving code between repositories by pmeunier on Tuesday July 07, 2026 @08:58AM (#48817110)
Pijul natively handles monorepos btw, that's the whole point.
Re:Google copybara: moving code between repositories by sluongng on Wednesday July 01, 2026 @01:09PM (#48750071)
Yeah I vibe coded https://github.com/sluongng/capyfun during a hackathon recently to add a generative transformation layer on top of the traditional imperative transformations.
Re:Google copybara: moving code between repositories by schrodinger on Tuesday June 30, 2026 @09:31PM (#48741388)
To those who have used it: is it handy for situations where you have multiple repos that want to share a little code, but it's not worth the trouble of extracting a library, referencing it, publishing versioned releases, updating dependent repos, etc?

And instead just "sync" a code folder from one main repo (perhaps containing common domain models) to other repos?

Basically the Go philosophy that a little bit of copying is better than a lot of dependency?

Re:Google copybara: moving code between repositories by ASinclair on Tuesday June 30, 2026 @10:03PM (#48741561)
It’s largely used for syncing external open source projects with the monorepo. Policy is to require source code imports over built artifacts. Though you can get exceptions.

Some projects are also developed in the monorepo and exported via Copybara.

My team also uses it to version Starlark rule sets internally.

Re:Google copybara: moving code between repositories by paulddraper on Tuesday June 30, 2026 @10:58PM (#48741790)
Source code imports versus artifacts really neither here nor there. Go is source code imports too.

The key part for Copybara is that Google will make changes to the OSS projects from within the internal repo and everyone else will make changes to the OSS projects.

Re:Google copybara: moving code between repositories by lwhi on Wednesday July 01, 2026 @05:16AM (#48744198)
I suppose it mitigates the potential risk of libraries being poisoned?
Re:Google copybara: moving code between repositories by baliex on Wednesday July 01, 2026 @06:26AM (#48744656)
Well kind of, or you just end up copying the poisoned version directly into your repo rather than having it as a dependency. Same outcome.

I suppose if you're running some security analysis on code in your own repo, the fact that you've copied the code in means that it'll run on your third party dependencies too, since they no longer appear to be third party.

Re:Google copybara: moving code between repositories by Ferret7446 on Thursday July 02, 2026 @06:42PM (#48768327)
It's mostly to track licensing, at least initially. The supply chain angle is a happy coincidence.
Re:Google copybara: moving code between repositories by xyzzy_plugh on Tuesday June 30, 2026 @10:04PM (#48741565)
It's for when you have a monorepo internally, and want to publish parts of it as open source to the world. They still need to live in the monorepo, so this is the solution.

Having a public repo as a dependency for your private corporate repo is a pain in the ass development-wise. Having a tree of such dependencies is a migraine.

Re:Google copybara: moving code between repositories by fipar on Wednesday July 01, 2026 @01:10AM (#48742490)
It can also be used if you want part of your monorepo to track something open source from the world.

Say, to rebase upstream MySQL changes onto a fork in the monorepo (in a random, non-specific example)

Re:Google copybara: moving code between repositories by yaskou on Wednesday July 01, 2026 @02:46AM (#48743100)
Yeah, that's the fun part. Probably built first for exporting monolith slices to OSS, but the reverse direction is more interesting to me. Tracking an upstream or keeping a private fork in sync. That's what makes Copybara useful well beyond the monorepo use case.
Re:Google copybara: moving code between repositories by klodolph on Wednesday July 01, 2026 @12:21AM (#48742208)
Copybara can do that but I think it will be annoying and tedious to use it that way. More annoying than the problem of extracting a library or shoving some files in a separate repo.
Re:Google copybara: moving code between repositories by xyzzy_plugh on Tuesday June 30, 2026 @10:07PM (#48741577)
Copybara is one of those things that you should have set up yesterday.

It works great and I've seen many teams gain significant productivity when collaborating in a monorepo with public bits.

If you're even toying with an internal monorepo you owe it to yourself to give it a try.

Re:Google copybara: moving code between repositories by jumploops on Tuesday June 30, 2026 @10:38PM (#48741703)
We’re in the process of open-sourcing a few sub-projects within a monorepo, and didn’t know this existed!

I’m curious what downsides folks have experienced with this tool?

Any tips?

Re:Google copybara: moving code between repositories by veyh on Wednesday July 01, 2026 @02:40AM (#48743075)
If you're exporting more than a few commits, I suggest using local repos (/path/to/.git) for both the source and destination. Otherwise it'll be quite slow.
Re:Google copybara: moving code between repositories by syngrog66 on Tuesday June 30, 2026 @10:42PM (#48741719)
That seems like a tool easily adoptable by folks engaging in dark patterns on GitHub, particularly the malware bait repos.
Re:Google copybara: moving code between repositories by alok-g on Tuesday June 30, 2026 @11:08PM (#48741843)
Interesting. Anyone knows how this compares to using git submodules and subtrees?

I had used those to create separate repo for website artifacts while the same also remain plugged into the webapp dev repo. (Both sides remain modifiable and changes mergeable to the other side.)

Thx.

Re:Google copybara: moving code between repositories by eddd-ddde on Wednesday July 01, 2026 @09:42AM (#48746653)
The main benefits you get are transformations. You can leverage tooling to automate include remapping and things like that.

But it's definitely not geared towards forks, but rather mirrors with deterministic and invertible transforms.

Re:Google copybara: moving code between repositories by neprotivo on Wednesday July 01, 2026 @12:14AM (#48742177)
If you are using Jujutsu you can achieve a basic way to maintain a public repo from a private monorepo with very little code and without Copybara. I wrote up how to do it here: https://vihren.dev/blog/20260625-jj-public-private-workflow/
Re:Google copybara: moving code between repositories by j2kun on Wednesday July 01, 2026 @12:15AM (#48742182)
The main function of copybara is not moving code but modifying code to make it suitable for a different repository structure, build system, etc.
Re:Google copybara: moving code between repositories by klodolph on Wednesday July 01, 2026 @12:17AM (#48742190)
Been using this for a while, mostly when I make a tool as part of a larger project and the tool is big enough to deserve its own release.

It’s powerful enough to do a whole bidirectional shipping operation where you export and import code—no thanks, that’s a hassle. I use it mostly for a simple fire and forget export, where I take a folder out of its original repo and preserve the history. Then I just move development to the new repo. The new project layout can be completely different, but Git blame works and I’m happy with that.

Re:Google copybara: moving code between repositories by rnagulapalle on Wednesday July 01, 2026 @12:45AM (#48742338)
The one-way pattern is actually how Google uses it internally too, syncing outward from their monorepo to GitHub. Bidirectional gets messy because transforms (path remapping, file exclusions, header stripping) are easy to apply in one direction but can't always be cleanly inverted. When both sides have diverged, Copybara's baseline tracking starts producing confusing results because semantically equivalent commits generate different SHAs after transform.

One thing worth knowing: history "preservation" is actually cherry-picks with rewritten commits, not a true transplant. Git blame works because the file content and authorship carry over, but the SHAs are new. Copybara embeds the original SHA in a commit message trailer (GitOrigin-RevId), which is useful to know if you ever need to correlate commits across repos after the fact.

Re:Google copybara: moving code between repositories by madeofpalk on Wednesday July 01, 2026 @03:43AM (#48743478)
> The one-way pattern is actually how Google uses it internally too, syncing outward from their monorepo to GitHub

Do they not support contributions on the public repos back into the internal monorepo?

Re:Google copybara: moving code between repositories by dmoy on Wednesday July 01, 2026 @03:49AM (#48743508)
There are three ways I've seen it done, though it being Google I assume there's more

One is to try the bidirectional support with copybara itself, thought that usually requires more effort than it's worth.

Another is to have the external repo be the source of truth and then always import into google3. Kythe used to do this at least, though I gather it's not done that way anymore.

The third is to just replicate the patches externally (which is pretty easy to automate or semi-automate on a case by case basis), and verify that a re-copybara-export keeps zero diff

Re:Google copybara: moving code between repositories by eddd-ddde on Wednesday July 01, 2026 @09:39AM (#48746599)
The "supported" workflow is you keep your source of truth in either the monorepo or the external repo. Then you export the current state of the source of truth to keep the mirrors up to date. Then, since we can assume the mirrors are up to date, the inverse transform can be applied to import change requests from the mirrors.

It works well when the assumptions hold, that there isn't large divergence on either side. It can actually be largely automated.

Re:Google copybara: moving code between repositories by tavianator on Thursday July 02, 2026 @06:28PM (#48768188)
Didn't Google have a tool for this called MOE (Make Open Easy) like 15 years ago? I remember it from some of my open source contributions to Guice
Re:Google copybara: moving code between repositories by willchen on Wednesday July 01, 2026 @01:47AM (#48742747)
i used this tool when i was at google, extremely helpful in open-sourcing things from google3 to github. still, i'm glad to just directly develop on github now :)
Re:Google copybara: moving code between repositories by the_dude_ on Wednesday July 01, 2026 @02:56AM (#48743167)
If the only need you need is sync repos without exclusions or transformations I wouldn't bother, it could work for you until it doesn't when they archive it or kill it like kaniko or so many other google products/tools.

Gitlab has really simple way to mirror from Gitlab to Github or other git vendors/servers

Re:Google copybara: moving code between repositories by vlovich123 on Wednesday July 01, 2026 @04:04AM (#48743596)
I really doubt copybara ever gets killed. AFAIK it’s a pretty central tool to google3 and how they maintain and vendor OSS projects at scale
Re:Google copybara: moving code between repositories by dmoy on Wednesday July 01, 2026 @03:45AM (#48743491)
yea copybara is really for doing transforms in one or both directions.

E.g. translating from external bzl to internal blaze BUILD compatibility, changing between external imports and internal third_party style imports, etc etc.

If it's a pure mirror, copybara is super overkill

Re:Google copybara: moving code between repositories by theodpHN on Wednesday July 01, 2026 @02:58AM (#48743176)
52+ years of progress... :-)

July, 2026: Google copybara allows one to move code between two prod repositories

March, 1974: IBM COPY allows one to move code between two prod partitioned data sets: OS/MVT and 0S/VS2 TSO Data Utilities COPY, FORMAT, LIST, MERGE User's Guide and Reference https://www.computinghistory.org.uk/downloads/8987

Re:Google copybara: moving code between repositories by theolivenbaum on Wednesday July 01, 2026 @04:15AM (#48743678)
Wild times when one can go from a HN post about an interesting open source code to a port to a new language in a matter of hours (wip, but almost complete: https://github.com/theolivenbaum/copybara)
Re:Google copybara: moving code between repositories by Gehinnn on Wednesday July 01, 2026 @04:23AM (#48743744)
Does this tool allow changes in both repositories? (with a 3 way merge strategy) git subtrees come close, but I have a use case where I need transformations/file filters on top.
Re:Google copybara: moving code between repositories by nbobko on Wednesday July 01, 2026 @05:33AM (#48744312)
At my previous company we tried to use this tool to sync parts of the code between two different git repos. The tool turned out being unacceptably slow.

Handwritten bash scripts using git-replace and git-filter-repo [1] did a much better job

[1]: https://github.com/newren/git-filter-repo

Re:Google copybara: moving code between repositories by whirlwin on Wednesday July 01, 2026 @05:55AM (#48744439)
Does anyone know if it is useful for bidirectional sync between codeberg and GitHub?
Re:Google copybara: moving code between repositories by krick on Wednesday July 01, 2026 @06:04AM (#48744499)
I get it that there are use-cases for this, but it's surprising to learn that apparently use-case space is big enough for it to invite a creation of a dedicated tool. I mean that the fact you need it is a bit shameful on its own, no? Usually, when you need to reuse the code between the projects, you try to extract it as a separate library / module. The copying between repos is just a lazy solution, because "ain't nobody got time for that".
Re:Google copybara: moving code between repositories by zem on Wednesday July 01, 2026 @06:22AM (#48744621)
it's useful for cases like google's, where they mirror internal code to github or vice versa, and the two versions need a bit of mechanical work every time they are synced (e.g. slightly different tree layout conventions, internal code or docs that you don't want to include in the github version, stripping of references to other internal stuff like bug IDs from comments, etc).
Re:Google copybara: moving code between repositories by krick on Wednesday July 01, 2026 @10:31AM (#48747470)
But if you are gonna extract and open-source the whole self-contained tool, why not just do that and then install in whatever project like you install any other 3rd party tool?
Re:Google copybara: moving code between repositories by zem on Wednesday July 01, 2026 @01:40PM (#48750518)
in order to use third party code within google it needs to be copied into the monorepo, and projects that depend on it need to import the internal version. this requires at the very least setting it up to build via blaze (google's internal build system, open sourced as bazel), and frequently adjusting its directory layout to fit the monorepo conventions.

this "mirror and use the local copy" dance is exactly how "any other third party tool" works within google.

Re:Google copybara: moving code between repositories by dijit on Wednesday July 01, 2026 @06:45AM (#48744775)
Ha! This post comes right at the time where I finally got around to open sourcing the patches I made to provide Perforce support which I use at my gamedev studio[0].

I find it kind of funny that perforce support was not included, only git support seems to exist in any meaningful way: despite the primary use of copybara being for releasing internal google code (which lives in Piper, a fork of Perforce).

I actually got a bit worried when looking at the git history before making the PR, because there's a lot of Gerrit Change-ID markers (meaning there's some gerrit code review system somewhere which I'm not privvy too) and I might have submitted a PR which never gets upstreamed..

I feel the same pang of pain from the lack of a perforce version of Gerrit/Rietveld.. but, you can't ask for everything!

[0]: https://github.com/google/copybara/pull/347

Re:Google copybara: moving code between repositories by Arainach on Wednesday July 01, 2026 @07:26AM (#48745044)
> which lives in Piper, a fork of Perforce

This is incorrect. Piper is API-compatible with Perforce but is a totally different implementation, not a fork.

Re:Google copybara: moving code between repositories by dijit on Wednesday July 01, 2026 @07:28AM (#48745059)
really? I thought Google had paid Perforce for a source license?

Maybe I am wrong.

Re:Google copybara: moving code between repositories by Arainach on Wednesday July 01, 2026 @07:48AM (#48745217)
Re:Google copybara: moving code between repositories by lima on Wednesday July 01, 2026 @06:59AM (#48744866)
Don't worry, they accept PRs on that repo. They just merge them internally and then re-export them.

There are some variations, but this is generally the same with all open source projects which live in their internal monorepo, such as gVisor or Bazel.

Re:Google copybara: moving code between repositories by bruckie on Wednesday July 01, 2026 @08:56AM (#48745956)
One reason there's no Perforce support for Gerrit/Rietveld is that Google doesn't use those tools for changes to code that's stored in Piper. Instead, they use Critique:

- https://abseil.io/resources/swe-book/html/ch19.html

- https://read.engineerscodex.com/p/how-google-takes-the-pain-...

I haven't found anything external that's as good, and am astounded that GitHub's incredibly lackluster PR review tooling is acceptable to most people. If anyone is aware of something in Critique's league, I'd love to hear about it!

Edit: I tried to do a reasonably thorough survey a couple of years ago when I left Google and https://codeapprove.com/ was the closest I found, but there were still many gaps.

Re:Google copybara: moving code between repositories by lima on Wednesday July 01, 2026 @12:03PM (#48749044)
Gerrit's new UI comes pretty close, and it's also what Google uses for projects living outside of google3.

GitHub's PR review workflow is archaic in comparison, especially now that every page takes 2-3 seconds to load.

Re:Google copybara: moving code between repositories by habosa on Thursday July 02, 2026 @07:21AM (#48759667)
Codeapprove creator here! I made it to fill the exact gap you're lamenting, and I still think that gap exists. For a while it seemed like Graphite was going to be the answer but over time they ended up focusing more on the AI angle and less on human review tooling and now it feels just as cluttered and slow as anything else.

I home some other Xoogler comes along and delivers a Critique build for 2026, I still think there's a need!

Re:Google copybara: moving code between repositories by ape4 on Wednesday July 01, 2026 @09:58AM (#48746905)
Why doesn't it have a capybara as its logo!
Re:Google copybara: moving code between repositories by bellowsgulch on Wednesday July 01, 2026 @10:01AM (#48746951)
Reminds me of git fetch-file.

“Fetch and sync individual files or globs from other Git repositories, with commit tracking and local-change protection”

https://github.com/andrewmcwattersandco/git-fetch-file

Re:Google copybara: moving code between repositories by cole_ on Wednesday July 01, 2026 @11:01AM (#48747971)
We used Copybara to setup a hub-and-spoke model at Dagster where public-facing repos can live within our larger internal monorepo, and while it worked we had to do a lot of hacky things.

https://dagster.io/blog/monorepos-the-hub-and-spoke-model-an...

Re:Google copybara: moving code between repositories by bellowsgulch on Wednesday July 01, 2026 @11:25AM (#48748429)
I already shared git-fetch-file in another comment here, but the .git-remote-files manifests seem a lot nicer than whatever this thing does:

    [file "lib/util.py" from "https://github.com/example/tools.git"]
    commit = a1b2c3d4e5f6789abcdef0123456789abcdef01
    branch = master
    comment = Common utility function

    [file "config.json" from "https://github.com/example/tools.git"]
    commit = b2c3d4e5f6789abcdef0123456789abcdef012
    branch = master
    target = vendor
    comment = Configuration from tools repo

    [file "helper.js" from "https://github.com/another/project.git"]
    commit = c3d4e5f6789abcdef0123456789abcdef0123
    branch = main
    comment = Helper from another project
vs

    core.workflow(
        name = "default",
        origin = git.github_origin(
        url = "https://github.com/google/copybara.git",
        ref = "master",
        ),
        destination = git.destination(
            url = "file:///tmp/foo",
        ),

        # Copy everything but don't remove a README_INTERNAL.txt file if it exists.
        destination_files = glob(["third_party/copybara/**"], exclude = ["README_INTERNAL.txt"]),

        authoring = authoring.pass_thru("Default email <[email protected]>"),
        transformations = [
            core.replace(
                    before = "//third_party/bazel/bashunit",
                    after = "//another/path:bashunit",
                    paths = glob(["**/BUILD"])),
            core.move("", "third_party/copybara")
        ],
    )
There seems to be an absolute ton of reference at https://github.com/google/copybara/blob/master/docs/referenc..., whereas I feel like all the people using git-fetch-file just want files from other repos, and sometimes to make some changes on those.
Re:Google copybara: moving code between repositories by DisagreeAndQuit on Wednesday July 01, 2026 @11:56AM (#48748925)
I work at Google and copybara workflows are the bane of my existence.
Re:Google copybara: moving code between repositories by nixosbestos on Wednesday July 01, 2026 @02:55PM (#48751559)
Very nosily, I'm curious what prominent projects Google hosts OSS but has a meaningfully private internal version.