如何从GitHub中的问题引用现有分支?

时间:2022-02-20 19:38:12

Let's say I have a branch named feature/1. And also issue #1. I want to link that branch to that issue.

假设我有一个名为feature / 1的分支。并且还发行#1。我想将该分支链接到该问题。

Is there a way to link that branch to that issue from the issue? Without making a commit.

有没有办法将该分支与该问题的问题联系起来?没有提交。

5 个解决方案

#1


70  

Directly from github:

直接来自github:

References

参考

Certain references are auto-linked:

某些引用是自动链接的:

  • SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • SHA:be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • 用户@ SHA ref:mojombo @ be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • 用户/项目@ SHA:mojombo / god @ be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • #Num: #1
  • #Num:#1
  • User/#Num: mojombo#1
  • 用户/ #Num:mojombo#1
  • User/Project#Num: mojombo/god#1
  • 用户/项目#Num:mojombo / god#1

It seems that directly (as in user/repo/branch) is not possible, but maybe by using the id of the tree?

似乎直接(如在user / repo / branch中)是不可能的,但可能通过使用树的id?

#2


63  

As mentioned in another answer, GitHub automatically makes links to various things, including other GH repositories, but not to branches within those repositories. When I want to do this, I manually make the link like this:

正如另一个答案中所提到的,GitHub会自动链接各种内容,包括其他GH存储库,但不会链接到这些存储库中的分支。当我想这样做时,我手动创建这样的链接:

[a link to a branch](/_user_/_project_/tree/_branch_)

Where _user_, _project_, and _branch_ should be replaced with the parts of the branch's URL. For example, a branch in GitHub's "linguist" project:

其中_user_,_project_和_branch_应替换为分支URL的部分。例如,GitHub的“语言学家”项目中的一个分支:

[api-changes branch in github/linguist](/github/linguist/tree/api-changes)

Important:

重要:

  • GitHub's Markdown processor creates links using the exact URL value enclosed within parentheses. You must specify the URL considering how a browser would handle that link. If the URL specified is only the path portion (as in this example), browsers will treat the path as relative to the current page's URL. If that relative path begins with a slash ("/", also as in this example), then it will be relative to the root of the server of the current page's URL. Otherwise, paths that don't begin with slash will be treated as relative to the parent of the current page's URL. (This is basic HTML link specification.)
  • GitHub的Markdown处理器使用括号内的精确URL值创建链接。您必须考虑浏览器如何处理该链接来指定URL。如果指定的URL仅是路径部分(如本例所示),则浏览器会将路径视为相对于当前页面的URL。如果该相对路径以斜杠(“/”,也在此示例中)开头,那么它将相对于当前页面的URL的服务器的根。否则,不以斜杠开头的路径将被视为相对于当前页面URL的父级。 (这是基本的HTML链接规范。)
  • Do not forget to include the tree part of the URL when referring to specific branches of projects.
  • 在引用项目的特定分支时,不要忘记包含URL的树部分。

#3


12  

Note that from April 2013 ("Branch and Tag Labels For Commit Pages"):

请注意,自2013年4月起(“提交页面的分支和标签标签”):

  • Any commit can mention the branch it is part of:
  • 任何提交都可以提及它所属的分支:

如何从GitHub中的问题引用现有分支?

If the commit is not on the default branch, the indicator will show the branches which contain the commit. If the commit is part of an unmerged pull request, a link will be shown.

如果提交不在默认分支上,则指示符将显示包含提交的分支。如果提交是未合并拉取请求的一部分,则将显示链接。

如何从GitHub中的问题引用现有分支?

That means referencing a commit from the issue will allow the user to see the branch (by looking at the commit), and even to see a link back to the issue (still by looking at the commit).

这意味着引用该问题的提交将允许用户查看分支(通过查看提交),甚至可以查看返回问题的链接(仍然通过查看提交)。

#4


5  

You can't reference the branch directly.

您无法直接引用该分支。

But you can make a reference to a branch compared to another branch. If you enter this:

但是,与其他分支相比,您可以引用分支。如果你输入这个:

https://github.com/user1/repo/compare/branch1...branch2

it will render as

它将呈现为

branch1...branch2

Also, you can compare branches across forks. If user2 has forked repo, this works:

此外,您可以比较叉子之间的分支。如果user2有分叉repo,这适用:

https://github.com/user1/repo/compare/branch1...user2:branch2

#5


0  

I was looking for the same possibility in Git, but nothing was available so I decided to directly refer the brach with a markdown link by using the Hash reference.

我在Git中寻找相同的可能性,但没有任何东西可用,所以我决定使用哈希参考直接通过降价链接引用brach。

# Issue02

## Commit Hash _<hash_number>_

...Rest of comments in the issue...

So, now in my organization we always do that reference when opening or closing an issue. It must be refered to a certain Hash and indirectly it is refered to the corresponding branch.

所以,现在在我的组织中,我们总是在打开或关闭问题时做这个参考。必须将其引用到某个Hash并间接地将其引用到相应的分支。

I guess you already now, but if not, to get the hash you will use git log

我猜你现在已经,但如果没有,要获得哈希,你将使用git log

Note: It is not referencing to a certaing branch but a commit,

注意:它不是引用一个certaing分支而是一个提交,

With some hours of work I think it is possible to automatically do this and create a command line tool,

经过几个小时的工作,我认为可以自动执行此操作并创建命令行工具,

#1


70  

Directly from github:

直接来自github:

References

参考

Certain references are auto-linked:

某些引用是自动链接的:

  • SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • SHA:be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • 用户@ SHA ref:mojombo @ be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • 用户/项目@ SHA:mojombo / god @ be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
  • #Num: #1
  • #Num:#1
  • User/#Num: mojombo#1
  • 用户/ #Num:mojombo#1
  • User/Project#Num: mojombo/god#1
  • 用户/项目#Num:mojombo / god#1

It seems that directly (as in user/repo/branch) is not possible, but maybe by using the id of the tree?

似乎直接(如在user / repo / branch中)是不可能的,但可能通过使用树的id?

#2


63  

As mentioned in another answer, GitHub automatically makes links to various things, including other GH repositories, but not to branches within those repositories. When I want to do this, I manually make the link like this:

正如另一个答案中所提到的,GitHub会自动链接各种内容,包括其他GH存储库,但不会链接到这些存储库中的分支。当我想这样做时,我手动创建这样的链接:

[a link to a branch](/_user_/_project_/tree/_branch_)

Where _user_, _project_, and _branch_ should be replaced with the parts of the branch's URL. For example, a branch in GitHub's "linguist" project:

其中_user_,_project_和_branch_应替换为分支URL的部分。例如,GitHub的“语言学家”项目中的一个分支:

[api-changes branch in github/linguist](/github/linguist/tree/api-changes)

Important:

重要:

  • GitHub's Markdown processor creates links using the exact URL value enclosed within parentheses. You must specify the URL considering how a browser would handle that link. If the URL specified is only the path portion (as in this example), browsers will treat the path as relative to the current page's URL. If that relative path begins with a slash ("/", also as in this example), then it will be relative to the root of the server of the current page's URL. Otherwise, paths that don't begin with slash will be treated as relative to the parent of the current page's URL. (This is basic HTML link specification.)
  • GitHub的Markdown处理器使用括号内的精确URL值创建链接。您必须考虑浏览器如何处理该链接来指定URL。如果指定的URL仅是路径部分(如本例所示),则浏览器会将路径视为相对于当前页面的URL。如果该相对路径以斜杠(“/”,也在此示例中)开头,那么它将相对于当前页面的URL的服务器的根。否则,不以斜杠开头的路径将被视为相对于当前页面URL的父级。 (这是基本的HTML链接规范。)
  • Do not forget to include the tree part of the URL when referring to specific branches of projects.
  • 在引用项目的特定分支时,不要忘记包含URL的树部分。

#3


12  

Note that from April 2013 ("Branch and Tag Labels For Commit Pages"):

请注意,自2013年4月起(“提交页面的分支和标签标签”):

  • Any commit can mention the branch it is part of:
  • 任何提交都可以提及它所属的分支:

如何从GitHub中的问题引用现有分支?

If the commit is not on the default branch, the indicator will show the branches which contain the commit. If the commit is part of an unmerged pull request, a link will be shown.

如果提交不在默认分支上,则指示符将显示包含提交的分支。如果提交是未合并拉取请求的一部分,则将显示链接。

如何从GitHub中的问题引用现有分支?

That means referencing a commit from the issue will allow the user to see the branch (by looking at the commit), and even to see a link back to the issue (still by looking at the commit).

这意味着引用该问题的提交将允许用户查看分支(通过查看提交),甚至可以查看返回问题的链接(仍然通过查看提交)。

#4


5  

You can't reference the branch directly.

您无法直接引用该分支。

But you can make a reference to a branch compared to another branch. If you enter this:

但是,与其他分支相比,您可以引用分支。如果你输入这个:

https://github.com/user1/repo/compare/branch1...branch2

it will render as

它将呈现为

branch1...branch2

Also, you can compare branches across forks. If user2 has forked repo, this works:

此外,您可以比较叉子之间的分支。如果user2有分叉repo,这适用:

https://github.com/user1/repo/compare/branch1...user2:branch2

#5


0  

I was looking for the same possibility in Git, but nothing was available so I decided to directly refer the brach with a markdown link by using the Hash reference.

我在Git中寻找相同的可能性,但没有任何东西可用,所以我决定使用哈希参考直接通过降价链接引用brach。

# Issue02

## Commit Hash _<hash_number>_

...Rest of comments in the issue...

So, now in my organization we always do that reference when opening or closing an issue. It must be refered to a certain Hash and indirectly it is refered to the corresponding branch.

所以,现在在我的组织中,我们总是在打开或关闭问题时做这个参考。必须将其引用到某个Hash并间接地将其引用到相应的分支。

I guess you already now, but if not, to get the hash you will use git log

我猜你现在已经,但如果没有,要获得哈希,你将使用git log

Note: It is not referencing to a certaing branch but a commit,

注意:它不是引用一个certaing分支而是一个提交,

With some hours of work I think it is possible to automatically do this and create a command line tool,

经过几个小时的工作,我认为可以自动执行此操作并创建命令行工具,