Git REST API-获取两个分支之间的差异

问题描述 投票:1回答:1

我们希望通过REST API来区分两个GitLab / GitHub分支。我们看到Git支持执行此操作的命令,但似乎他们不支持REST API。是否对此有任何API支持?

git diff --name-status firstbranch..yourBranchName

git diff --name-status origin/develop..origin/master

Showing which files have changed between two revisions

github-api gitlab-api
1个回答
1
投票

GitHub具有comparing branches的专用URL(非REST)。示例:

https://github.com/octocat/linguist/compare/master...octocat:an-example-comparison-for-docs

与GitLab相同:

https://gitlab.com/gitlab-org/gitlab-foss/compare?from=master&to=master

尽管可以是different from a git diff


用于GitHub的REST API将是:“ Compare two commits

GET /repos/:owner/:repo/compare/:base...:head

响应还包括两次提交之间更改的文件的详细信息。这包括更改的状态(例如,是否添加,删除,修改或重命名了文件),以及更改本身的详细信息。例如,状态为重命名的文件的previous_filename字段显示文件的前一个文件名,状态为modified的文件的修补程序字段显示对文件的更改。

对于GitLab:compare branch API

GET /projects/:id/repository/compare?from=master&to=feature
© www.soinside.com 2019 - 2024. All rights reserved.