git - 如何使用 stash rest api 获取分支头提交

标签 git bitbucket-server

我在从 stash 分支获取 HEAD 提交时遇到了一些问题。我可以使用以下 REST 调用获取分支提交。

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits?until={branch Name}

我还可以使用 /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/HEAD 在 master 中获取 HEAD 提交

我想知道如何使用 Stash REST API 获取分支 HEAD 提交。

最佳答案

对于下面没有正斜杠的分支名称是完美的:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/develop
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/master

但是当引用类似 feature/JIRA-123-foo-bar 的分支时,这会失败。
或者你可以调用

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/branches

这将为您提供所有分支及其最新提交。参见 Stash API documentation更多

关于git - 如何使用 stash rest api 获取分支头提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35598976/

相关文章:

bitbucket-server - stash api 的日期格式是什么?

git - 如何将多个远程设备的git-lfs流量定向到单个端点?

linux - 为什么git创建权限错误的文件?

git - Jenkins 和 Git 子模块的问题

java - Git rebase : Failed on patch deleting a file that got already modified

Git checkout 另一个分支

python - 如何使用 gitPython 将 'pipe' 密码发送到 remote.update()

git - 在 Eclipse Ubuntu 中重新索引存储库

java - 为数组字段添加 setter 时 ActiveObjects 抛出异常

git - 更改了用户名以推送到 atlassian stash - update-server-info?