Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git mirror without forced pushes

Tags:

git

Is it possible somehow to set up a git repository that works as a usual --mirror for pulling into it, but without forcing when pushing from it to another repo?

like image 263
gsakkis Avatar asked Feb 01 '13 09:02

gsakkis


2 Answers

You can just add --no-force to disable the forcing behavior like so:

git push --mirror --no-force

This will disable non-fast-forward updates (tested with git 1.8.0.2).

like image 190
Matthijs P Avatar answered Oct 31 '22 14:10

Matthijs P


I'd like to do a git push --mirror that will fail if a non-fast forward update is required.

A git push --mirror should fail if the upstream repo has its config set to receive.denyNonFastForwards true:

git config man page:

receive.denyNonFastForwards

If set to true, git-receive-pack will deny a ref update which is not a fast-forward.
Use this to prevent such an update via a push, even if that push is forced.
This configuration variable is set when initializing a shared repository.

That means you wouldn"t have to "reproduce what --mirror" does: you could simply use it, and still have that push fail if any non-fastforward merge is involved.

like image 45
VonC Avatar answered Oct 31 '22 12:10

VonC