我正在使用 Atlassian Stash(Bitbucket 服务器)来管理我的 git 存储库。最近我需要使用 Stash REST API 将文件(新创建的 .xml 文件)提交到我的 Git 存储库。 .我已经阅读了文档,但 REST API 似乎不支持该功能。
我是否正确,或者这是否可能?
最佳答案
可能你正在寻找
PUT /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*}
来自API的文档
PUT /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*}
Update the content of path, on the given repository and branch. This resource accepts PUT multipart form data, containing the file in a form-field named content. An example curl request to update 'README.md' would be:
curl -X PUT -u username:password -F content=@README.md -F 'message=Updated using file-edit REST API' -F branch=master -F sourceCommitId=5636641a50b http://example.com/rest/api/latest/projects/PROJECT_1/repos/repo_1/browse/README.md
- branch:应该修改或创建路径的分支
- content:路径文件的完整内容 message:消息 与此更改相关联,用作提交消息。或空 是否应使用默认消息。
- sourceCommitId:提交 ID 文件在被编辑之前的状态,用于识别内容是否已被编辑 变了。如果这是一个新文件,则为 null。
文件可以更新或 在新分支上创建。在这种情况下,sourceBranch 参数 应提供以确定新分支的起点 branch 参数标识创建新分支的分支 promise 。
关于git - 使用 Stash(bitbucket 服务器)REST API 将文件提交到 git 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40037984/