mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
Error when pushing to renamed repository #12200
Closed
opened 2025-11-02 10:01:46 -06:00 by GiteaMirror
·
51 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1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
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#12200
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lafriks on GitHub (Dec 13, 2023).
Description
When pushing to/pulling from renamed repository there is error:
Gitea Version
1.21.2
Can you reproduce the bug on the Gitea demo site?
Yes
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Binary
Database
PostgreSQL
@lunny commented on GitHub (Dec 17, 2023):
Did you push to the old name or the new name?
@PsychotherapistSam commented on GitHub (Dec 21, 2023):
Hi, same issue here: When pushing to the old URL of a repo that has been moved (in my case from a user to an org), I get the same error. Setting the new remote URL works, of course.
@lafriks commented on GitHub (Dec 28, 2023):
When pushing to the old remote url, also by just renaming without changing owner
@lunny commented on GitHub (Dec 28, 2023):
What's the expectation? Should it be allowed to redirect to the real repository or should it return the 404?
@chris-08154711 commented on GitHub (Jan 10, 2024):
Same here. Seems like the 1.21.2 update (or previous) broke the redirect functionality for renamed repos or organization or when moving a repo from one orga to another.
Before it was possible to rename/move a repo/orga and still use (fetch, pull, push) the local copy without having to "fix" the remote url. Gitea redirected from the previous remote url to the new location/name automatically.
There was a warning on the console that the operation is executed on a redirected URL.
Please fix! Its a pita to rename an organization with certain number of repos and users without this feature!
@lafriks commented on GitHub (Jan 22, 2024):
Previously it allowed to push to old remote url and it would still work as it was pushed to new repo location
@techknowlogick commented on GitHub (Jan 22, 2024):
Interesting, it appears as though this is because git doesn't accept redirect headers, and we must've previously accepted pushes to renamed repos with a 200 instead of a 308.
This is also interesting as we allow pushes with or without .git trailing, so there should be similar logic.
@lunny commented on GitHub (Feb 19, 2024):
I cannot reproduce this on main branch with http clone/pull/push when renaming the repository under the same user and also transfer to another org.
@chris-08154711 commented on GitHub (Feb 19, 2024):
Steps to reproduce:
@chris-08154711 commented on GitHub (Feb 20, 2024):
@lunny comment above updated with steps and screenshots (sorry, was in a hurry yesterday and couldn't complete the post)
gitea version: 1.21.1
git client version: git version 2.41.0.windows.3
@newgreenshoot commented on GitHub (Mar 1, 2024):
Just from attempting to quickly bisect this, the last tagged release where this worked was 1.21.0-rc2, and all subsequent versions can't pull/push from renamed repositories when using the old repository URL.
My team suspects that this PR introduced it: https://github.com/go-gitea/gitea/pull/27875
@lunny commented on GitHub (Mar 2, 2024):
It works for me on main branch.

@j123b567 commented on GitHub (Mar 5, 2024):
gitea: 1.21.5
git client: 2.44.0 and 2.43.0 on linux
gitea is behind reverse proxy using Apache 2.4.57
Running
git clonewithGIT_CURL_VERBOSE=1andGIT_TRACE=1. This is HTTP communication from the trace.Same error
error: RPC failed; HTTP 307 curl 22 The requested URL returned error: 307@le-patenteux commented on GitHub (Mar 5, 2024):
I can confirm the issue. Using Gitea 1.21.7 with docker from the linuxserver.io image.
Since we are a small team, I simply had to reset the git origin on my local clone to the new name, but I had to look around for 30 minutes before I found the issue!
Good luck all
@newgreenshoot commented on GitHub (May 29, 2024):
What sorts of setups are other people using? Is Gitea running behind a reverse proxy? Are you requiring HTTP authentication? I'm starting to wonder if there's some specific configuration detail that's responsible for this, since @lunny can't reproduce it under normal conditions. https://github.com/go-gitea/gitea/pull/27875 certainly seems to be responsible though.
This appears to still affect v1.22.0, and my organization is unable to update past v1.21.0-rc2 due to this.
@netsrotr commented on GitHub (Jul 22, 2024):
We have an possibly related issue renaming a branch via our gitea v 1.21.4 website. If we are at the "branches" view, and try to rename a branch via "rename" symbol at the right side of the branch in question, we get back an http error 404.
@robertschulze commented on GitHub (Jul 30, 2024):
We have the same issue in 1.21.10. It appears an upgrade will not solve it, is it correct?
@robertschulze commented on GitHub (Jul 30, 2024):
Yes, we are running Gitea behind a reverse proxy (Apache 2.4.58).
@netsrotr commented on GitHub (Jul 30, 2024):
Gitea is running behind a apache proxy.
@le-patenteux commented on GitHub (Jul 30, 2024):
Gitea behind swag (NGINX), authentication by Gitea itself for me.
I can't say if the issue has returned as we did not rename a repo since the incident in march
@winston0410 commented on GitHub (Oct 5, 2024):
I encountered this issue, after changing my username.
@lunny commented on GitHub (Oct 5, 2024):
Please confirm with no reverse proxy after you upgrade to 1.22.2 and I still cannot reproduce it in main branch and 1.22.2 .
@GiteaBot commented on GitHub (Nov 5, 2024):
We close issues that need feedback from the author if there were no new comments for a month. 🍵
@lunny commented on GitHub (Nov 5, 2024):
@lafriks Can you confirm this is still a problem?
@netsrotr commented on GitHub (Nov 5, 2024):
Rename branch with v1.22.3 works now--Gesendet mit der GMX Mail AppAm 05.11.24, 06:54 schrieb Lunny Xiao @.***>:
@lafriks Can you confirm this is still a problem?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
@GalaxySnail commented on GitHub (Dec 17, 2024):
This is still a problem after we upgraded to 1.22.6. We are running gitea behind caddy.
@lunny commented on GitHub (Dec 17, 2024):
Can you reproduce it on demo site?
@GalaxySnail commented on GitHub (Dec 17, 2024):
How to reproduce it on demo site? It requires a renamed repo, but I can't figure out which repo is renamed on demo site.
@lunny commented on GitHub (Dec 17, 2024):
You can create a new repository -> rename it and push a commit to the new repository.
@GalaxySnail commented on GitHub (Dec 18, 2024):
I can't reproduce it on demo site. These are HTTP requests sent by
git remote show originon our gitea instance:It seems related to the fact that we enabled
[service].REQUIRE_SIGNIN_VIEW.@lunny commented on GitHub (Dec 18, 2024):
Looks like you are using cloudflare as reverse proxy? Have you tried to push with SSH protocol or without any reverse proxy?
@GalaxySnail commented on GitHub (Dec 19, 2024):
I tried it over ssh tunnel without any reverse proxy, and the result is still the same.
@GiteaBot commented on GitHub (Jan 19, 2025):
We close issues that need feedback from the author if there were no new comments for a month. 🍵
@GalaxySnail commented on GitHub (Jan 19, 2025):
not stale
@maxsargentdev commented on GitHub (Feb 11, 2025):
Hey Guys,
Just bumped into this, I resolved it by setting this setting:
git config --global http.followRedirects true
This might be the difference people are seeing.
@lunny commented on GitHub (Feb 11, 2025):
In the server side or client side?
@maxsargentdev commented on GitHub (Feb 11, 2025):
Client side 👍
@lunny commented on GitHub (Feb 11, 2025):
@maxsargentdev Thank you for the workaround.
@lafriks can you confirm this resolved your problem?
@GiteaBot commented on GitHub (Mar 13, 2025):
We close issues that need feedback from the author if there were no new comments for a month. 🍵
@newgreenshoot commented on GitHub (Mar 14, 2025):
Though that config option works around the issue, this is still a regression in Gitea since previous versions (as well as Github and Gitlab) don't require it to be set for Git clients to act on renamed repositories.
Why is it returning 307 instead of 301? At a glance, it seems like Git will always follow a 301 "Moved Permanently" but it won't follow a 302 or 307 by default, hence the need for setting http.followRedirects client-side.
Could this issue be reopened, again?
@lunny commented on GitHub (Mar 14, 2025):
The status code changed from #18063, maybe we can change it back.
@lafriks commented on GitHub (Mar 25, 2025):
I think for git client requests it should be changed back
@silverwind commented on GitHub (Mar 25, 2025):
Where is this info from? Did you dig it out of git source code? The docs on
followRedirectsmakes no mention of any status codes.@silverwind commented on GitHub (Mar 25, 2025):
Digging deeper, the default option seems to map to CURLOPT_FOLLOWLOCATION=0, but alas, curl docs only say that 0 means disabled, e.g. I would assume 0 would not follow any redirects.
@newgreenshoot commented on GitHub (Mar 26, 2025):
I'm not sure that commit solved it. Old Reddit threads suggested it didn't handle 307s well, but in practice, it seems to treat them the same. Bad hunch on my part, I should've tested it more carefully before publicly guessing.
It's worth stressing that other projects had this issue before after Git stopped following redirects by default, see https://github.com/niemeyer/gopkg/issues/50
Additionally, Git should (with its default configuration!) still be able to fetch a renamed repo:
I mentioned before that my team bisected this issue to being introduced in https://github.com/go-gitea/gitea/pull/27875. Given that this issue only happens on instances with REQUIRE_SIGNIN_VIEW set, it's surely related to the change introduced in "send 401 first if http requires login"?
@wxiaoguang commented on GitHub (Mar 26, 2025):
Hmm, yes, it seems that #27875 just copied the code and there is no comment to explain why.
Now the "askAuth" logic just duplicates @lunny
@lunny commented on GitHub (Mar 27, 2025):
I sent #34032 which is an improvement of #27875 . I don't know whether it will fix this problem.
@wxiaoguang commented on GitHub (Mar 27, 2025):
Could you reproduce it on your side and/or add some tests?
@lunny commented on GitHub (Mar 27, 2025):
I can add a test but I cannot reproduce it in my dev env.
@wxiaoguang commented on GitHub (Mar 27, 2025):
But it can be reproduced, no idea why you can't .....
Behavior before #27875 (
git fetchcould work)Behavior after #27875 (
git fetchdoesn't work)Your PR #34032 is not right, it still behaves as "Behavior after #27875 (
git fetchdoesn't work)"@wxiaoguang commented on GitHub (Mar 27, 2025):
The correct fix should be like this: Fix git client accessing renamed repo #34034