我尝试了以下请求:
curl -v -X POST --header "PRIVATE-TOKEN:myPrivateToken" 'url-of-gitlab/api/v3/projects/myProjectId/repository/files?file_path=1.json&branch_name=master&content=thefilecontent&commit_message=ACommitMessage'
然而,我总是得到
"message":"You can only create files if you are on top of a branch"
在回复中。我不知道我的请求中缺少什么。 存储库是新创建的,我通过Gitlab UI创建它。也许我需要先创建一个分支?任何帮助都可以。非常感谢你。
答案 0 :(得分:2)
新创建了存储库,我通过Gitlab UI创建了它。
新创建的仓库(通过GitLab甚至是本地的简单git init
)具有无分支(并且没有HEAD)。
这就是我在“Why do I need to explicitly push a new branch?”中描述的内容。
也许我需要先创建一个分支?
是的,你做(至少有一个master
分支)