git - 使用 Stash(bitbucket 服务器)REST API 将文件提交到 git 存储库

标签 git bitbucket-server bitbucket-api

我正在使用 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/

相关文章:

git - 项目管理软件,可用选项

java - 如何通过 Rest API 使用提交 Id 从 Bitbucket 下载文件?

json - 从 Bitbucket 中检索文本文件内容

git - 如何在本地删除分支?

git - git 提交的 "-a"选项如何写入提交消息?

git - 我的 Azure Pipeline 使用哪个分支?

git - 如何在 SourceTree 中连接到我自己的 Git 服务器?

linux - 在 bash 脚本中,git 无法识别它自己的目录?

jenkins - 在 Jenkins 2.0 多分支管道上使用 stash notifier 插件

python - curl vs python "requests"访问 API 时