push to create is not working #8094

Closed
opened 2025-11-02 07:53:43 -06:00 by GiteaMirror · 11 comments
Owner

Originally created by @EngelPika32 on GitHub (Nov 11, 2021).

Gitea Version

1.15.6 built with GNU Make 4.3, go1.16.9 : bindata, timetzdata, sqlite, sqlite_unlock_notify

Git Version

2.30.2

Operating System

Linux, Arch (using docker)

How are you running Gitea?

using docker; behind a caddy-webserver. The webserver handles HTTPS.

server-image: gitea:1.15-rootless
db-image: postgres:13

Database

PostgreSQL

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Description

How to enable push-to-create? The option doesn't seem to exist anymore, hence it's a bug, I suppose.

Using login credentials (name & pw).

User-Log:

git remote add origin https://***sub.domain.tld***/***USER***/***REPO***.git
git push --set-upstream origin master

Username for 'https://***sub.domain.tld***': ***USER***
Password for 'https://***USER***@***sub.domain.tld***':
remote: Push to create is not enabled for users.
fatal: unable to access 'https://***sub.domain.tld***/***USER***/***REPO***.git/': The requested URL returned error: 403

Server-Log:

gitea       | 2021-11-11T16:26:15.498667083Z 2021/11/11 17:26:15 Started GET /***USER***/***REPO***.git/info/refs?service=git-receive-pack for IP_AND_PORT
gitea       | 2021-11-11T16:26:15.566583212Z 2021/11/11 17:26:15 ...s/context/context.go:331:HandleText() [E] Push to create is not enabled for users.
gitea       | 2021-11-11T16:26:15.566625221Z 2021/11/11 17:26:15 Completed GET /***USER***/***REPO***.git/info/refs?service=git-receive-pack 403 Forbidden in 67.381684ms

From the Docs here :

ENABLE_PUSH_CREATE_USER: false: Allow users to push local repositories to Gitea and have them automatically created for a user.

However, when searching for this option in app.example.ini, I can't find it.
Setting it changes nothing.

Pushing to a newly created repo does work fine.

Screenshots

No response

Originally created by @EngelPika32 on GitHub (Nov 11, 2021). ### Gitea Version 1.15.6 built with GNU Make 4.3, go1.16.9 : bindata, timetzdata, sqlite, sqlite_unlock_notify ### Git Version 2.30.2 ### Operating System Linux, Arch (using docker) ### How are you running Gitea? using docker; behind a caddy-webserver. The webserver handles HTTPS. server-image: gitea:1.15-rootless db-image: postgres:13 ### Database PostgreSQL ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Description How to enable push-to-create? The option doesn't seem to exist anymore, hence it's a bug, I suppose. Using login credentials (name & pw). User-Log: ``` git remote add origin https://***sub.domain.tld***/***USER***/***REPO***.git git push --set-upstream origin master Username for 'https://***sub.domain.tld***': ***USER*** Password for 'https://***USER***@***sub.domain.tld***': remote: Push to create is not enabled for users. fatal: unable to access 'https://***sub.domain.tld***/***USER***/***REPO***.git/': The requested URL returned error: 403 ``` Server-Log: ``` gitea | 2021-11-11T16:26:15.498667083Z 2021/11/11 17:26:15 Started GET /***USER***/***REPO***.git/info/refs?service=git-receive-pack for IP_AND_PORT gitea | 2021-11-11T16:26:15.566583212Z 2021/11/11 17:26:15 ...s/context/context.go:331:HandleText() [E] Push to create is not enabled for users. gitea | 2021-11-11T16:26:15.566625221Z 2021/11/11 17:26:15 Completed GET /***USER***/***REPO***.git/info/refs?service=git-receive-pack 403 Forbidden in 67.381684ms ``` From the Docs [here](https://docs.gitea.io/en-us/config-cheat-sheet/) : ``` ENABLE_PUSH_CREATE_USER: false: Allow users to push local repositories to Gitea and have them automatically created for a user. ``` However, when searching for this option in [app.example.ini](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini), I can't find it. Setting it changes nothing. Pushing to a newly created repo does work fine. ### Screenshots _No response_
GiteaMirror added the issue/needs-feedbackissue/not-a-bug labels 2025-11-02 07:53:43 -06:00
Author
Owner

@jolheiser commented on GitHub (Nov 11, 2021):

I'm not sure why it's not in the example config, but it is still documented as you mentioned.

Did you put it in the right section and restart gitea?

@jolheiser commented on GitHub (Nov 11, 2021): I'm not sure why it's not in the example config, but it is still documented as you mentioned. Did you put it in the right section and restart gitea?
Author
Owner

@EngelPika32 commented on GitHub (Nov 11, 2021):

Should be alright(?):

[repository]
ENABLE_PUSH_CREATE_USER = true

I restarted the container (to be sure), hence yes.


It's the same app.ini as all the other configs, which are shown correctly on the admin/config dashboard.
(And I just noticed, there isn't a 'repository' section on that page.)

@EngelPika32 commented on GitHub (Nov 11, 2021): Should be alright(?): ``` [repository] ENABLE_PUSH_CREATE_USER = true ``` I restarted the container (to be sure), hence yes. ----- It's the same app.ini as all the other configs, which are shown correctly on the admin/config dashboard. *(And I just noticed, there isn't a 'repository' section on that page.)*
Author
Owner

@jolheiser commented on GitHub (Nov 12, 2021):

That looks good to me. I will try on a test instance later, but given we have tests for this I'm inclined to think it shouldn't be broken. (But I won't rule it out!)

@jolheiser commented on GitHub (Nov 12, 2021): That looks good to me. I will try on a test instance later, but given we have tests for this I'm inclined to think it shouldn't be broken. (But I won't rule it out!)
Author
Owner

@Vincevrp commented on GitHub (Dec 13, 2021):

I'm experiencing the same issue on gitea:1.15.7. ENABLE_PUSH_CREATE_USER=true does not seem to be working.

@Vincevrp commented on GitHub (Dec 13, 2021): I'm experiencing the same issue on gitea:1.15.7. `ENABLE_PUSH_CREATE_USER=true` does not seem to be working.
Author
Owner

@jolheiser commented on GitHub (Dec 13, 2021):

I've just tested this on my 1.15.7 instance (as well as a fresh test instance) and had no issues.

Can you double (triple) check that the config is set correctly?

@jolheiser commented on GitHub (Dec 13, 2021): I've just tested this on my 1.15.7 instance (as well as a fresh test instance) and had no issues. Can you double (triple) check that the config is set correctly?
Author
Owner

@Vincevrp commented on GitHub (Dec 13, 2021):

I found the issue. The environment variable for the Docker image should be GITEA__REPOSITORY__ENABLE_PUSH_CREATE_USER=true instead of ENABLE_PUSH_CREATE_USER=true, as documented here.

@Vincevrp commented on GitHub (Dec 13, 2021): I found the issue. The environment variable for the Docker image should be `GITEA__REPOSITORY__ENABLE_PUSH_CREATE_USER=true` instead of `ENABLE_PUSH_CREATE_USER=true`, as documented [here](https://docs.gitea.io/en-us/install-with-docker/#managing-deployments-with-environment-variables).
Author
Owner

@delanym commented on GitHub (Jan 13, 2022):

The issue persists with gitea/gitea image version 1.15.9 after setting env vars

ENABLE_PUSH_CREATE_USER=true
ENABLE_PUSH_CREATE_ORG=true
ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false

But I notice these config values don't appear on the /admin/config

@delanym commented on GitHub (Jan 13, 2022): The issue persists with gitea/gitea image version 1.15.9 after setting env vars ``` ENABLE_PUSH_CREATE_USER=true ENABLE_PUSH_CREATE_ORG=true ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false ``` But I notice these config values don't appear on the <host>/admin/config
Author
Owner

@zeripath commented on GitHub (Jan 13, 2022):

The issue persists with gitea/gitea image version 1.15.9 after setting env vars

This is not how you set environment variables that you want to be mapped to the app.ini

If you intend these settings to be environment variables:

ENABLE_PUSH_CREATE_USER=true
ENABLE_PUSH_CREATE_ORG=true
ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false

You need to set the following environment variables (as it is clearly stated in https://docs.gitea.io/en-us/install-with-docker/#managing-deployments-with-environment-variables and as https://github.com/go-gitea/gitea/issues/17619#issuecomment-992920809 says):

GITEA__repository__ENABLE_PUSH_CREATE_USER=true
GITEA__repository__ENABLE_PUSH_CREATE_ORG=true
GITEA__repository__ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false

Or you can set them directly in your app.ini as:

[repository]
ENABLE_PUSH_CREATE_USER=true
ENABLE_PUSH_CREATE_ORG=true
ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false

environment-to-ini is very simple. The environment variable GITEA__section__KEY=value becomes the ini [section] KEY=value. This means we can map ANY ini value from ANY section to an environment variable. (There are a few special cases which I will add below.)

Special cases: ini sections with "." & "-" in them

Environment variables are usually restricted to a reduced character
set "0-9A-Z_" - in order to allow the setting of sections with
characters outside of that set, they should be escaped as following:
"0X2E" for "." and "0X2D" for "-". The entire section and key names
can be escaped as a UTF8 byte string if necessary. E.g. to configure:

...
[log.console]
COLORIZE=false
STDERR=true
...

You would set the environment variables: GITEA__LOG_0x2E_CONSOLE__COLORIZE=false
and GITEA__LOG_0x2E_CONSOLE__STDERR=false. Other examples can be found
on the configuration cheat sheet.


I think you need to explain what page or documentation provided by Gitea is telling you to set the above as environment variables.

@zeripath commented on GitHub (Jan 13, 2022): > The issue persists with gitea/gitea image version 1.15.9 after setting env vars This is not how you set environment variables that you want to be mapped to the app.ini If you intend these settings to be environment variables: > ``` > ENABLE_PUSH_CREATE_USER=true > ENABLE_PUSH_CREATE_ORG=true > ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false > ``` You need to set the following environment variables (as it is clearly stated in https://docs.gitea.io/en-us/install-with-docker/#managing-deployments-with-environment-variables and as https://github.com/go-gitea/gitea/issues/17619#issuecomment-992920809 says): ``` GITEA__repository__ENABLE_PUSH_CREATE_USER=true GITEA__repository__ENABLE_PUSH_CREATE_ORG=true GITEA__repository__ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false ``` Or you can set them directly in your app.ini as: ```ini [repository] ENABLE_PUSH_CREATE_USER=true ENABLE_PUSH_CREATE_ORG=true ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false ``` environment-to-ini is very simple. The environment variable `GITEA__section__KEY=value` becomes the ini `[section]` `KEY=value`. This means we can map ANY ini value from ANY section to an environment variable. (There are a few special cases which I will add below.) ## Special cases: ini sections with "." & "-" in them Environment variables are usually restricted to a reduced character set "0-9A-Z_" - in order to allow the setting of sections with characters outside of that set, they should be escaped as following: "_0X2E_" for "." and "_0X2D_" for "-". The entire section and key names can be escaped as a UTF8 byte string if necessary. E.g. to configure: ```ini ... [log.console] COLORIZE=false STDERR=true ... ``` You would set the environment variables: `GITEA__LOG_0x2E_CONSOLE__COLORIZE=false` and `GITEA__LOG_0x2E_CONSOLE__STDERR=false`. Other examples can be found on the configuration cheat sheet. --- I think you need to explain what page or documentation provided by Gitea is telling you to set the above as environment variables.
Author
Owner

@zeripath commented on GitHub (Jan 13, 2022):

Actually I'm going to close this bug - once we find out what documentation is giving the incorrect impression we can update that but this isn't a bug.

@zeripath commented on GitHub (Jan 13, 2022): Actually I'm going to close this bug - once we find out what documentation is giving the incorrect impression we can update that but this isn't a bug.
Author
Owner

@EngelPika32 commented on GitHub (Jan 21, 2022):

@zeripath Sorry for not being active. I somehow forgot this issue over Christmas/new year.

Unfortunately, I'd call this issue being "highjacked" (though by accident). However, I'm glad others found their solution^.
I'm currently on 1.15.10 and the original issue (with its description) still persists.
And here is why:

First: The original issue was using gitea-data/custom/conf/app.ini – hence, a config file and not environment vars.
(IMHO the docs state pretty clearly, how to set environment).

Second: app.example.ini does not list ENABLE_PUSH_CREATE_USER nor ENABLE_PUSH_CREATE_ORG and ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET is listed under [security] and not [repository]

The docs (that) say

The defaults provided here are best-effort (not built automatically). They are accurately recorded in app.example.ini (s/main/<tag|release>).

How comes, that valid configuration is listed in the docs, but not in the supposedly generated and complete app.example.ini?
(Though, I dunno if it's generated, but it sounds so… and it sounds to claim to be complete)

Third: None of the above explains why <your-instance>.tld/admin/config doesn't list the config (as said by myself and delanym).

Fourth: The "does-work" solution seems to be: 'Set ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false' for… reasons??. app.example.ini notes this as "NOT RECOMMENDED" – with no explanation of what it actually does or what a complete environment is. (Can't find this in the docs either.)


Now, I did some testing with the newly earned knowledge.

  • ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false seems to be required for this feature (push-to-create) to work.
  • It does not seem to matter if it's set via app.ini or environment. Environment working more reliably? [see below] (gitea will set the value in /etc/gitea/app.ini as well)
  • I have to notice some issues between /etc/gitea/app.ini and custom/conf/app.ini. Some configuration of the latter is ignored. In my case, some UI configuration. However, I have to note, when I first set up gitea, some configuration options worked from custom/conf/app.ini only.
    Though, I have no clue what's the deal between these two and why they don't work well with each other. afaik the one in etc is generated and set by gitea itself, while the one in custom/conf is for the admin to alter the configuration. afaik custom/conf takes precedence over /etc. – Though, I'm not sure about that.

Overall: Yes, the comments here helped and push-to-create is currently working for me. However, I'm pretty much clueless about said issues and left confused in the dark. Although it does work "de-facto", it doesn't feel like the issue is solved.

PS: I leave it up to you whether this should be moved into a new issue or not (as it doesn't matter for me).

@EngelPika32 commented on GitHub (Jan 21, 2022): @zeripath Sorry for not being active. I somehow forgot this issue over Christmas/new year. Unfortunately, I'd call this issue being "highjacked" (though by accident). However, I'm glad others found their solution^. I'm currently on 1.15.10 and the original issue (with its description) still persists. And here is why: First: The original issue was using `gitea-data/custom/conf/app.ini` – hence, a config file and not environment vars. (IMHO the docs state pretty clearly, how to set environment). Second: [app.example.ini](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini) does not list `ENABLE_PUSH_CREATE_USER` nor `ENABLE_PUSH_CREATE_ORG` and `ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET` is listed under `[security]` and not `[repository]` The docs ([that](https://docs.gitea.io/en-us/config-cheat-sheet/)) say > The defaults provided here are best-effort (not built automatically). They are accurately recorded in app.example.ini (s/main/<tag|release>). How comes, that valid configuration is listed in the docs, but not in the supposedly generated and complete app.example.ini? *(Though, I dunno if it's generated, but it sounds so… and it sounds to claim to be complete)* Third: None of the above explains why `<your-instance>.tld/admin/config` doesn't list the config (as said by myself and delanym). Fourth: The "does-work" solution seems to be: 'Set `ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false`' for… reasons??. [app.example.ini](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini) notes this as "NOT RECOMMENDED" – with no explanation of what it actually does or what a complete environment is. (Can't find this in the docs either.) - - - - - Now, I did some testing with the newly earned knowledge. - `ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false` seems to be required for this feature (push-to-create) to work. - It does not seem to matter if it's set via app.ini or environment. Environment working more reliably? *[see below]* (gitea will set the value in `/etc/gitea/app.ini` as well) - I have to notice some issues between `/etc/gitea/app.ini` and `custom/conf/app.ini`. Some configuration of the latter is ignored. In my case, some UI configuration. However, I have to note, when I first set up gitea, some configuration options worked from `custom/conf/app.ini` only. Though, I have no clue what's the deal between these two and why they don't work well with each other. afaik the one in etc is generated and set by gitea itself, while the one in custom/conf is for the admin to alter the configuration. afaik custom/conf takes precedence over /etc. – Though, I'm not sure about that. - - - - - Overall: Yes, the comments here helped and push-to-create is currently working for me. However, I'm pretty much clueless about said issues and left confused in the dark. Although it does work "de-facto", it doesn't feel like the issue is solved. PS: I leave it up to you whether this should be moved into a new issue or not (as it doesn't matter for me).
Author
Owner

@jolheiser commented on GitHub (Jan 21, 2022):

I am a bit confused where ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET came into the picture, it should be entirely irrelevant to push-create. (and indeed it works fine both in test and on my real instance where I've left it out completely and it's therefore set to default true)

As well, ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET is mostly undocumented because we don't want users to bypass the Gitea environment. Setting your own Gitea environment is intentionally left as an exercise to the reader because we don't recommend it.

Regarding push-create not existing in the sample config, it seems it was removed when we refactored and commented out the sample config because it was being copy/pasted. We should potentially re-visit #15807 as it seems to have unintentionally removed some of the options.

Gitea only uses a single config, there is no /etc/gitea/app.ini vs custom/conf/app.ini. Likely the difference is whether you run the binary yourself or have systemd run it. The docs cover how to set the config path when running manually.


From what I can tell in this thread, there is no bug present. Feel free to open a new issue if you encounter something else. 🙂

@jolheiser commented on GitHub (Jan 21, 2022): I am a bit confused where `ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET` came into the picture, it should be entirely irrelevant to push-create. (and indeed it works fine both in test and on my real instance where I've left it out completely and it's therefore set to default `true`) As well, `ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET` is mostly undocumented because we don't want users to bypass the Gitea environment. Setting your own Gitea environment is intentionally left as an exercise to the reader because we don't recommend it. Regarding push-create not existing in the sample config, it seems it was removed when we refactored and commented out the sample config because it was being copy/pasted. We should potentially re-visit #15807 as it seems to have unintentionally removed some of the options. Gitea only uses a single config, there is no `/etc/gitea/app.ini` vs `custom/conf/app.ini`. Likely the difference is whether you run the binary yourself or have systemd run it. The [docs](https://docs.gitea.io/en-us/install-from-binary/#2-running-from-command-lineterminal) cover how to set the config path when running manually. ----- From what I can tell in this thread, there is no bug present. Feel free to open a new issue if you encounter something else. 🙂
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8094