Unable to sync remote private repo with public - copybara from example blog.

27 views
Skip to first unread message

Mwiza Simbeye

unread,
Feb 22, 2025, 2:58:52 PMFeb 22
to Copybara OSS
Hi All,

I have a copybara config similar to the one in the blog (https://blog.kubesimplify.com/moving-code-between-git-repositories-with-copybara#heading-annex-how-to-install-copybara), however; when I try the push command (from private to public), I get the following error:

ERROR: Error executing 'git fetch ssh://g...@github.com/<redacted>/copybara-demo-public.git --verbose --progress -f refs/heads/master:refs/copybara_fetch/refs/heads/master'(exit code 1). Stderr: error: cannot lock ref 'refs/copybara_fetch/refs/heads/master': 'refs/copybara_fetch/refs/heads/master/copybara_full_ref' exists; cannot create 'refs/copybara_fetch/refs/heads/master'

From ssh://github.com/<redacted>/copybara-demo-public

 ! [new branch]      master     -> refs/copybara_fetch/refs/heads/master  (unable to update local ref)

error: some local refs could not be updated; try running

 'git remote prune ssh://g...@github.com/<redacted>/copybara-demo-public.git' to remove any old, conflicting branches

Config: 
core.workflow(
    name = "pull",                                 # <- renamed to pull
    origin = git.origin(
        url = sourceUrl,
        ref = "master",
    ),
    destination = git.github_pr_destination(
        url = destinationUrl,
        destination_ref = "master",
        pr_branch = "from_public_repo",
        title = "pr from external public repo",
        body = "this is a sample pull request",
        integrates = [],
    ),
    destination_files = glob(["external/**"]),
    authoring = authoring.pass_thru("Copybara <>"),
    transformations = [
        core.move("", "external"),
    ],
)

core.workflow(
    name = "push",                                 # <- created
    origin = git.origin(
        url = destinationUrl,
        ref = "master",
    ),
    destination = git.github_pr_destination(
        url = sourceUrl,
        destination_ref = "master",
        pr_branch = "from_monorepo",
        title = "pr from monorepo",
        body = "this is a sample pull request",
        integrates = [],
    ),
    origin_files = glob(["external/**"]),  # pay attention!
    authoring = authoring.pass_thru("Copybara <>"),
    transformations = [
        core.move("external", ""),
    ],
)

any ideas on how to solve this? 

Thanks 

Reply all
Reply to author
Forward
0 new messages