#4930 Local branches in projects configured with mirroring do not persist
Opened 3 years ago by ngompa. Modified 3 years ago

I discovered that my btrfs-progs-fedora project (which mirrors upstream btrfs-progs) lost its local branches (which do not exist upstream) on the next sync from upstream.

This behavior is inconsistent with how Git mirroring works by default in other forges (GitLab for example).

Now, it'd be good to have a way to configure this behavior, but this behavior should not be default.


I discovered that my btrfs-progs-fedora project (which mirrors upstream btrfs-progs) lost its local branches (which do not exist upstream) on the next sync from upstream.

This behavior is inconsistent with how Git mirroring works by default in other forges (GitLab for example).

In other forges maybe, but by default git push --mirror, which is basically
what pagure does, overrides everything on the receiving end.

Is there a way to make it so git push --mirror can be configured to not do that?

Is there a way to make it so git push --mirror can be configured to not do that?

If you find a way to do this via the git CLI, we can easily adjust pagure to do this as well.

we can't do it with git cli right now as is, since we are not able to difference between local branches and former remote ones.

Problematic scenario:

  • We mirror $REMOTE on $LOCAL, remote has four branches: branch-a, branch-b, branch-c, branch-d .
  • We create a local branch, branch-e
  • Someone removes branch-c on remote
  • We start syncing again. How the hell we know that we have to keep branch-e but remove branch-c ? We can't right now.

Same applies for tags.

So, first of all we need to track local refs locally. We could adapt our hooks to add a second ref on refs/locals/{branch,tag} when someone pushes a {branch,tag} into a mirror repo on pagure.

Once we get there, we can difference local branches/tags from removed old remote ones, so we could backup local refs into a temporary repo, git --mirror the main repo, and repush the local branches (and their refs on refs/local/*) to it from the temporary one.

Login to comment on this ticket.

Metadata