What is the difference between git push --all
and git push --mirror
?
I only know this:
--all
doesn't push it and --mirror
does.This is correct?
Any other differences?
As it says in the documentation:
--all
Push all branches (i.e. refs under
refs/heads/
); cannot be used with other <refspec>.--mirror
... specifies that all refs under
refs/
(which includes but is not limited torefs/heads/
,refs/remotes/
, andrefs/tags/
) be mirrored ...
So a, if not the, key difference is that one means refs/heads/*
and one means refs/*
. The refs/heads/*
names are the branch names. Anything in refs/remotes/
is a remote-tracking name, and anything in refs/tags/
is a tag name. Other notable name-spaces include refs/notes/
, refs/replace/
, and the singular refs/stash
.
The --mirror
option goes on to mention:
locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end.
Hence --mirror
effectively implies both --force
and --prune
; --all
does not. You can, however, add --force
and/or --prune
to git push --all
, if you like.
It is always up to the other Git to decide whether to obey polite requests (those sent without --force
) or commands (--force
) to make changes to its references.
With deleted local branch,
--all
doesn't push it and--mirror
does.
This is a consequence of the --prune
option: telling your Git to use --prune
means "ask them to delete names in their name-space(s) that are not in mine".