Gitlab:不能只推送到掌握

Jim*_*m C 2 git gitlab

我找不到能够在 master 以外的任何分支中推送更改的原因。我的意思是,我通过将代码推送到 gitlab 来创建主分支。然后,任何将更改推送到主分支的尝试都失败了。尽管如此,我用另一个名为 develop 的分支复制了我的 master 分支,我可以在它上面推送我的更改。为了简单起见,让我把我在谷歌搜索一段时间后所做的一切:

C:\dev\test>git fetch --all
Fetching origin

C:\dev\test>git reset --hard origin/master
HEAD is now at 64031f0 just created by generator

... some changes via my editor ....

C:\dev\test>git commit -a -m "changed project name"
[master 5abf2f2] changed project name
 1 file changed, 5 insertions(+), 5 deletions(-)

C:\dev\test>git push -u origin/master
fatal: 'origin/master' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

C:\dev\test>git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 365 bytes | 365.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Error: This is the master branch, and the commit has no merge request
remote: 64031f03f1723e3399ad467dbbb536942fe144f0 5abf2f29e0ced51289d1fcd684b1510acd354764 refs/heads/master
To ssh://gitlab.mycomp.net:2222/myportfolio/mycomp-app-sf-just-test.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://git@gitlab.mycomp.net:2222/myportfolio/mycomp-app-sf-just-test.git'

C:\dev\test>git push -u origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 365 bytes | 365.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Error: This is the master branch, and the commit has no merge request
remote: 64031f03f1723e3399ad467dbbb536942fe144f0 5abf2f29e0ced51289d1fcd684b1510acd354764 refs/heads/master
To ssh://gitlab.mycomp.net:2222/myportfolio/mycomp-app-sf-just-test.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://git@gitlab.mycomp.net:2222/myportfolio/mycomp-app-sf-just-test.git'
Run Code Online (Sandbox Code Playgroud)

简而言之,我看到的大多数答案都告诉要么使用 git push -u 要么取消对分支的保护。现在我的 gitlab 项目分支不受保护,正如您所看到的,我正在使用 -u

小智 6

这里的问题是默认情况下 master 分支受保护。如果您想使用存储库设置 -> 受保护分支下的“取消保护”按钮,您可以更改该设置 此外,您还可以更改合并的分支可访问性设置,推送维护人员,开发人员级别。有关更多详细信息,请参阅屏幕。

在此处输入图片说明