无法将文件推送到 git,原因是:未能推送一些引用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52026119/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 13:10:35  来源:igfitidea点击:

Unable to push files to git due to: failed to push some refs

gitgitlab

提问by Omri

I have a directory that i want to turn into a git project.

我有一个目录,我想把它变成一个 git 项目。

I created a new project in gitlab and then i did the following:

我在 gitlab 中创建了一个新项目,然后我执行了以下操作:

git init
git remote add origin [email protected]:a/b/c.git
git add .
git commit -m "Initial commit"
git push -u origin master

In addition, I created the following .gitignorefile:

此外,我创建了以下.gitignore文件:

*
!*/scripts
!*/jobs

After running git push -u origin masteri got the following error:

运行后,git push -u origin master我收到以下错误:

Counting objects: 33165, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (32577/32577), done.
Writing objects: 100% (33165/33165), 359.84 MiB | 1.70 MiB/s, done.
Total 33165 (delta 21011), reused 0 (delta 0)
remote: Resolving deltas: 100% (21011/21011), done.
remote: GitLab: 
remote: A default branch (e.g. master) does not yet exist for a/b/c
remote: Ask a project Owner or Maintainer to create a default branch:
remote: 
remote:   https://gitlab.com/a/b/c/project_members
remote: 
To gitlab.com:a/b/c.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:a/b/c.git'

What could be the issue? Please advise

可能是什么问题?请指教

采纳答案by VonC

This is linked to issue 27456and merge request 6608:

这与问题 27456合并请求 6608 相关联

document the need to be owner or have the master permission level for the initial push

记录需要成为所有者或具有初始推送的主权限级别

So it might be a permission level, not a branch issue.

所以这可能是权限级别,而不是分支问题。

See commit 81ee443:

请参阅提交 81ee443

You will need to be owner or have the master permission level for the initial push, as the master branch is automatically protected.

您需要是所有者或拥有初始推送的主权限级别,因为主分支是自动保护的。