I tried the following request:
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'
However, I invariably get
"message":"You can only create files if you are on top of a branch"
in the response. I don't know what's missing from my request. The repository is newly created and I created it through the Gitlab UI. Maybe I need to create a branch first? Any help would do. Thank you very much.
The repository is newly created and I created it through the Gitlab UI.
A newly created repo (through GitLab or even a simple git init
locally) has no branches (and no HEAD).
This is what I describe in " Why do I need to explicitly push a new branch? ".
Maybe I need to create a branch first?
Yes, you do (at least a master
branch)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.