Push Mirrors: Option to disable force-push #9533

Open
opened 2025-11-02 08:42:05 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @noerw on GitHub (Sep 7, 2022).

Feature Description

Push mirrors currently do force pushes for push mirrors, implying the assumption that the source repo is the single source of truth.
But consider this use case:

  1. find a repo on $nonfederating-forge
  2. fork the repo on $nonfederating-forge
  3. add the repo to gitea, to work in a familiar environment
  4. set up push mirror in gitea to fork on $nonfederating-forge
  5. create PR in source repo on $nonfederating-forge
  6. owner of the source repo makes changes to the PR branch

gitea will overwrite the changes made by the original repo maintainer when mirroring.
This is not desired and causes confusion as can be seen in https://github.com/xperimental/nextcloud-exporter/pull/65#issuecomment-1230026287

Screenshots

No response

Originally created by @noerw on GitHub (Sep 7, 2022). ### Feature Description Push mirrors currently do force pushes for push mirrors, implying the assumption that the source repo is the single source of truth. But consider this use case: 1. find a repo on $nonfederating-forge 2. fork the repo on $nonfederating-forge 3. add the repo to gitea, to work in a familiar environment 4. set up push mirror in gitea to fork on $nonfederating-forge 5. create PR in source repo on $nonfederating-forge 6. owner of the source repo makes changes to the PR branch gitea will overwrite the changes made by the original repo maintainer when mirroring. This is not desired and causes confusion as can be seen in https://github.com/xperimental/nextcloud-exporter/pull/65#issuecomment-1230026287 ### Screenshots _No response_
GiteaMirror added the type/enhancementtype/proposal labels 2025-11-02 08:42:05 -06:00
Author
Owner

@corytodd commented on GitHub (Apr 26, 2023):

This would be useful for us as well. We found that the git config options are ignored so that --mirror and --force are always supplied, regardless of the remote_mirror_$random mirror and push values.

I was thinking we could implement this in two PRs.

  1. Remove the hard coded force and mirror parameters so that the git config is respected. Users that wish to disable mirroring and/or force pushes can edit the git config and things will just work. Existing users will be unaffected.
  2. Extend PushMirror to make the mirror and force flags dynamic. Update API and frontend accordingly.

Is summary, assuming that git v2.0.0 is really the minimum required version, git should should not need to be told explicitly to use --mirror and --force.

If there is a maintainer that thinks this is a reasonable plan, please let me know and we'll get started on it.

@corytodd commented on GitHub (Apr 26, 2023): This would be useful for us as well. We [found](https://github.com/go-gitea/gitea/blob/8f57aa014b5642bcd33a6b22492df3c63f03d808/services/mirror/mirror_push.go#L158) that the git config options are ignored so that --mirror and --force are always supplied, regardless of the `remote_mirror_$random` mirror and push values. I was thinking we could implement this in two PRs. 1. Remove the hard coded force and mirror parameters so that the git config is respected. Users that wish to disable mirroring and/or force pushes can edit the git config and things will just work. Existing users will be unaffected. 2. Extend PushMirror to make the mirror and force flags dynamic. Update API and frontend accordingly. Is summary, assuming that git v2.0.0 is really the minimum required version, git should should not need to be told explicitly to use --mirror and --force. If there is a maintainer that thinks this is a reasonable plan, please let me know and we'll get started on it.
Author
Owner

@Dreamail commented on GitHub (Jan 13, 2024):

waiting for update

@Dreamail commented on GitHub (Jan 13, 2024): waiting for update
Author
Owner

@mio-19 commented on GitHub (Mar 5, 2024):

Pull Mirrors also need an option to disable force-push. I opened an issue for pull mirrors https://github.com/go-gitea/gitea/issues/29604

@mio-19 commented on GitHub (Mar 5, 2024): Pull Mirrors also need an option to disable force-push. I opened an issue for pull mirrors https://github.com/go-gitea/gitea/issues/29604
Author
Owner

@cuantar commented on GitHub (Aug 5, 2024):

Interested in this as well.

@cuantar commented on GitHub (Aug 5, 2024): Interested in this as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9533