20

Nearly every issue I file on gh refers to code on a particular branch. Does github have any mechanism to link an issue to the branch?

I need to filter issues by branch, so I am not distracted by issues in other feature branches.

Is there a way to do this? I know milestones can be (ab)used to reach a similar effect, but things get really confusing when the branch becomes a pull request and it shows up as another issue.

Mahozad
  • 18,032
  • 13
  • 118
  • 133
Eric Vicenti
  • 1,928
  • 1
  • 16
  • 16

3 Answers3

11

References Often times issues are dependent on other issues, or at least relate to them and you’d like to connect the two. You can reference issues by typing in a hashtag plus the issue number.

Hey @kneath, I think the problem started in #42

Issue in another repository? Just include the repository before the name like kneath/example-project#42.

One of the more interesting ways to use GitHub Issues is to reference issues directly from commits. Include the issue number inside of the commit message.

By prefacing your commits with “Fixes”, “Fixed”, “Fix”, “Closes”, “Closed”, or “Close” when the commit is merged into master, it will also automatically close the issue.

References make it possible to deeply connect the work being done with the bug being tracked, and are a great way to add visibility into the history of your project.

Data Travel
  • 134
  • 1
  • 4
5

Since March 2022, you can:

Create a branch for an issue

You can now create a branch directly from an issue to begin development work that's correlated to that issue.

Branches connected to an issue are shown under the "Development" section, which has replaced "Linked pull requests", in the sidebar of an issue.

When you create a pull request for one of these branches, it is automatically linked to the issue.

For more information, see the documentation.

Here is an animated image showing how a branch is created for an issue.
After creation, the linked branch is shown in the Development section:

https://i2.wp.com/user-images.githubusercontent.com/3369400/155508406-6b71c98a-2884-4ea9-9bc0-e47015976366.gif?ssl=1

The OP asked:

I need to filter issues by branch, so I am not distracted by issues in other feature branches.

It is still in public beta, but the new Development section can help you list branches associated to issues:

https://docs.github.com/assets/cb-37995/images/help/issues/create-a-branch.png

So for any issue you need to work on, create a new branch:

https://docs.github.com/assets/cb-48946/images/help/issues/create-a-branch-options.png

Matt
  • 12,848
  • 2
  • 31
  • 53
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    How can I do it manually? Like other services, say, containing issue number? – Jin Kwon May 22 '22 at 06:00
  • 1
    I don't see any API yet for this. You can [create a branch through API](https://stackoverflow.com/a/9513594/6309), but without linking it directly to an issue. – VonC May 22 '22 at 08:44
3

Use labels to organize issues. They aren't inherently branch-specific, but you could make a tag for each branch if that is how you want them organized.

When you have admin access to the repository, there should be a button called 'manage labels' on the issue page. That will let you add, modify, or delete labels. You can apply labels to issues a few different ways. One way is to open the issue and click the labels button just to the right of the main body of text for the issue. Once you have created a label, it will appear on the left just above the manage labels button. You can click on each label to view all the issues that have been marked with that label.

IanH
  • 10,250
  • 1
  • 28
  • 32