git 如何在 IntelliJ IDEA 中查看拉取请求?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40217494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:34:53  来源:igfitidea点击:

How to review a pull request in intelliJ IDEA?

gitintellij-ideabitbucket

提问by galusben

We are using git, bitbucket, and IntelliJ IDEA. The project is mainly written in Java and Groovy.

我们正在使用 git、bitbucket 和 IntelliJ IDEA。该项目主要用Java和Groovy编写。

Is there a good way to review pull requests right from IntelliJ?

有没有一种直接从 IntelliJ 拉取请求的好方法?

采纳答案by VonC

The formal support for GitHub (or BitBucket for that matter) pull request review is still pending (issue IDEA-85079, opened in 2012)

对 GitHub(或 BitBucket)拉取请求的正式支持仍在等待中(issueIDEA-85079,于 2012 年开放)

Since 2016, It has support for GitHub PR in 2018.3, as commented here:

自2016年,它在2018.3对GitHub的公关支持,因为在这里评论

This is mostly read-only mode for now - one could create a local branch from a PR or open it on GitHub to comment/close it - but this is only the first step.

In future releases we plan to add additional functionality - ability to assign PRs IDEA-146659, merge/close them directly from IDE, comment on the PR and specific lines of code - IDEA-64794.

目前这主要是只读模式 - 可以从 PR 创建本地分支或在 GitHub 上打开它以评论/关闭它 - 但这只是第一步。

在未来的版本中,我们计划添加额外的功能 - 分配 PR 的能力IDEA-146659,直接从 IDE 合并/关闭它们,评论 PR 和特定的代码行 - IDEA-64794

But: (Sept. 2019)

但是:(2019 年 9 月

It's not at all obvious how to open the PR page. I had to look up the release notes to discover it's a double click. Discoverability of the PR tab is also poor; it isn't visible by default and there's no way to reach it from the version control tab, which is where I looked first.

如何打开 PR 页面一点也不明显。我不得不查看发行说明才能发现它是双击。PR 选项卡的可发现性也很差;默认情况下它不可见,并且无法从版本控制选项卡访问它,这是我首先查看的位置。

Jan. 2020: Dan Oakmentions in the commentsthat:

2020 年 1 月:Dan Oak在评论中提到:

CodeStreamprovides a tool to integrate GitHub PRs into IDEA.
See Pull Request Integrations:

CodeStream can display merged pull request comments in your editor as annotations on the current version of your

CodeStream提供了将 GitHub PR 集成到 IDEA 中的工具。
请参阅拉取请求集成

CodeStream 可以在您的编辑器中显示合并的拉取请求注释作为当前版本的注释



2016:

2016年:

That leaves you with a manual process, fetching a PR, and comparing the branches:

这给您留下了一个手动过程,获取 PR 并比较分支:

git fetch origin pull/1234/head:pr-1234

For BitBucket:

对于比特桶

git fetch origin refs/pull-requests/1234/from:pr-1234

(See also "How to fetch Pull Requests in BitBucket")

(另请参阅“如何在 BitBucket 中获取拉取请求”)

Then you can compare branches in IntelliJ.

然后你可以比较 IntelliJ 中的分支

回答by payne

Apparently, IntelliJ now supports reviewing Pull Requests.

显然,IntelliJ 现在支持 Pull Requests

Select Main menu | VCS | Git | View Pull Requestsand view the state of a PR, current label, and assignee, if any. In the right pane, you can view the altered files and use the diff to preview the changes.

We plan to add actions such as merge, close, comment, and more in the forthcoming releases. For now, you can create a local branch from a PR via the context menu and then merge it as a regular branch. From the same context menu, you can quickly open a pull request on github.com.

enter image description here

You can promptly find the PR you need by searching by state, assignee, author, after, before, or sort by. By the way, autocompletion is available in this search field as well.

enter image description here

选择主菜单 | 风险控制 | git | 查看拉取请求并查看 PR、当前标签和受让人(如果有)的状态。在右侧窗格中,您可以查看更改的文件并使用差异来预览更改。

我们计划在即将发布的版本中添加合并、关闭、评论等操作。现在,您可以通过上下文菜单从 PR 创建本地分支,然后将其合并为常规分支。从同一个上下文菜单中,您可以快速打开 github.com 上的拉取请求。

在此处输入图片说明

您可以通过按州、受让人、作者、之后、之前或排序方式快速找到您需要的 PR。顺便说一句,此搜索字段中也可以使用自动完成功能。

在此处输入图片说明

EDIT: Many comments are pointing to the fact that apparently this feature only works for GitHub.

编辑:许多评论都指出这个功能显然只适用于 GitHub。

回答by Vasilis Mavromatis

I find it easier to append fetch = +refs/pull/*/head:refs/remotes/origin/pr/*under [remote "origin"] section inside .git/config so it looks like this:

我发现fetch = +refs/pull/*/head:refs/remotes/origin/pr/*在 .git/config 中的 [remote "origin"] 部分下附加更容易,所以它看起来像这样:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = xxxxxxxxxxxxxxx.git
    fetch = +refs/pull/*/head:refs/remotes/origin/pr/*

And then git fetch originfetches all pull requests. I think this should work for BitBucket too though I haven't tested it.

然后git fetch origin获取所有拉取请求。我认为这也适用于 BitBucket,尽管我还没有测试过。

回答by KayV

To view the Pull request and changes, use the following steps in Intellij:

要查看拉取请求和更改,请在 Intellij 中使用以下步骤:

  1. Go to version control.
  2. Click logs. There will a list of all commits.
  3. Select a perticular commits.
  4. On the right window, you will get the list of changes in this commit.
  5. Select show parent changes.
  6. Click on the files which show changes and then you will able to see all the code changes.
  1. 转到版本控制。
  2. 单击日志。将有一个所有提交的列表。
  3. 选择特定的提交。
  4. 在右侧窗口中,您将获得此提交中的更改列表。
  5. 选择显示父更改。
  6. 单击显示更改的文件,然后您将能够看到所有代码更改。