我想在没有git工具的情况下在 GitHub 存储库上创建(推送)新文件,(因为该工具在我的主机git上不可用)。PHP所以我做了一些研究,发现了GitHub REST API。
我尝试使用curl个人访问令牌来上传或修改我的仓库中的文件。这是curl我找到的一个 shell 代码,并进行了如下更改:
curl -i https://api.github.com/repos/username/repo/newFile.txt -X PUT
\ -H 'Authorization: token xxxxxxxxxxxxxxxxxxxx' -d "{\"path\": \"newFile.txt\",
\ \"message\": \"update\", \"content\": \"$(openssl base64 -A -in newFile.txt)\", \"branch\":
\"master\",
\ \"sha\": $(curl -X GET https://api.github.com/repos/username/repo/newFile.txt | jq .sha)}"
但我收到此错误:
HTTP/1.1 404 未找到
服务器:GitHub.com
我该如何解决这个问题?
PS 即使push file by emailGitHub 或 (GitLab) 上有服务,这也可以帮助通过电子邮件在我的 repo 上创建文件。