Why does git push
result in forced update, causing lost commits on the origin?
What can be done to prevent this?
push.default
set to simple
Based on some searching it is probably connected to the +
sign in remote.origin.fetch
setting, but when i clone a fresh repo, the +
sign is already there (so it's not caused by me messing with the repo).
If you saw in the config the .mirror
option, then it makes sense that a git push overrides everything:
remote.<name>.mirror
If true, pushing to this remote will automatically behave as if the
--mirror
option was given on the command line.
You can do it with git config remote.backup.mirror true
.
If you have access to the remote repo settings, then you could do a:
git config receive.denyNonFastForwards true
in order to prevent those forced push.
But this isn't yet supported on a remote repo like GitHub for instance.