Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push --all vs --mirror

Tags:

git

github

push

What is the difference between git push --all and git push --mirror?

I only know this:

  • With deleted local branch, --all doesn't push it and --mirror does.

This is correct?

Any other differences?

like image 347
Dani Avatar asked Mar 17 '18 23:03

Dani


People also ask

What does git push mirror do?

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.

What does git push -- all do?

Push all of your local branches to the specified remote. Tags are not automatically pushed when you push a branch or use the --all option. The --tags flag sends all of your local tags to the remote repository.

Does git push all commits?

No, git push only pushes commits from current local branch to remote branch that you specified in command.

Does git push all include tags?

Sharing Tags If you have a lot of tags that you want to push up at once, you can also use the --tags option to the git push command. This will transfer all of your tags to the remote server that are not already there.


1 Answers

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 to refs/heads/, refs/remotes/, and refs/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".

like image 135
torek Avatar answered Oct 03 '22 22:10

torek