The reason you see something pushed the second time is that --mirror
pushes a little more than you expect. Apart from your local branches, it also pushes your remote branches, because mirror implies everything. So when you push normally (or with --mirror
), mybranch
is pushed and origin/mybranch
is updated to reflect the new status on origin. When you push with --mirror
, origin/mybranch
is also pushed.
This results in the strangeness you see, and also in a worse strangeness when you pull from that remote; you would get branches named origin/origin/mybranch
etc. So it’s usually best to use --mirror
for one time copies, and just use normal push (maybe with --all
) for normal uses.
To always push all branches and tags, you can update .git/config
like so:
[remote "origin"]
url = ...
fetch = ...
push = +refs/heads/*
push = +refs/tags/*
That will make a normal push similar to a mirror, except that it won’t delete branches that don’t exist at the source or for non-fast-forward updates.