How to associate GitHub issues with a branch? - github

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.

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.

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:
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:
So for any issue you need to work on, create a new branch:

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.

Related

GitHub - Create issues specific to a branch?

what I want to do is the exact opposite of what people normally do.
I want to create GitHub issues that apply only to a particular branch I'm currently working on. Ideally, they would not be visible when browsing other branches of the repo. Even more ideally, they would only be visible to the repo owner (me).
To give a little more context, I'm working on the next version of a rather large macOS app, and the new issues I want to create would only be relevant to this new version, not to the master branch (old app version). That is why I want these issues to only be associated with a specific branch, not with the repo as a whole.
I know that I can associate an issue with a "project" or "milestone" but I'm looking for something different.
Any ideas ? Thanks.
This is not possible. Issues are repository wide. You can add in the title or body of the issue that it is for a specific branch. Or you can use labels saying what branch it is for. You can also make a branch for the issue (if you have write access to the repository) differentiation it even more. And for when the PR is made you can link it.

Do numbers in git branch names associate with GitHub Issues?

I am trying to learn about git/GitHub workflow. I'm on branches, and learning about the different typical branch name prefixes. I've read several of the key articles.
If I name a branch issue-*, you can correspond that to an existing issue in the GitHub issue tracker by adding its number, like issue-32, is that right?
Is this number only for the developer's own tracking, or does it actually get associated with the issue, such that the branch somehow appears linked on the issue?
If a topic branch named like issue-32 does form an association with the issue, would other conceivable topic group prefixes do the same? Ie. If you were storing a feature note as issue 76, does branch feature-something-76 make any association with it?
Thinking it through, am I wrong to think that a branch could be associated with an issue? Is it, rather, that you associate commits with issues? And, if that's the case for issue-*, it's also the case for feature-*?
Ie. Should I only ever be referencing issue numbers in a commit message, eg. "Fixes issue #32" (and is there any particular nomenclature required beside use of the integer?)?
This answer shows GitHub, only a few weeks ago, introduced a new feature to create a new branch from an existing issue. But that's a) the other way around from my question and b) from the web (not sure how I'd do this in VS Code). Also seems like the linkage only happens upon a pull request.

Github - remove repository from list on main page

On github's main page there is a list of repositories on the left. I got on this list repo "alanxz/rabbitmq-c". It is not forked. I'm not a contributor. It simply sits there. I suppose that it was added when I filled an issue there, but it was closed and I have no longer use for this repository.
When I go to Setting -> Your repositories, it isn't there. When I go to Personal settings -> Repositories, it isn't there. I have no way to remove it, I can't leave (as I'm not a contributor) and I can't remove it (as it isn't forked). The following questions are similar but do not apply or are identical but lack answers:
GitHub: Remove a repository from "Your Repositories"? (similiar, but that's not it)
how to remove 'Repositories you contribute to' in github mainpage (seems like exactly same problem, but no answers)
Remove external github repository from https://github.com/ landing page (no answers)
How can I remove this entry?
First of all, that repository list sorts based on most recent activity. So, if you had recently contributed to that repo, it would be showing up there. That’s expected behavior.
The list does update automatically as you make new contributions to other repos. So, as long as you don’t make anymore contributions to the vuepress repo, you should see its name fall further down the “Respositories” list over time.
As for manually removing it, that isn’t currently possible. The dashboard view where you see that “Repositories” list is only viewable to you, and again, the list is sorted automatically based on recent activity. That all said, I can understand why you may like to remove a recently contributed to repository from that list.
Cheers!
Per #SinisterDeveloper there does not seem to be a way to remove something from the list.
However, you may find things at the very top of the list that you were once interested in but not anymore.
If you select that project and then look on the upper right, if it is marked as "Watch" or "Unwatch", then click it and select "Ignore". It seems like that might cause it to gradually drop down the list and ultimately disappear since it will no longer be seeing activity from others contributing to the repository.
At least I hope this works ...

Create new branch from the Issue

Is it possible to create new branch directly from Issue which is posted on Github? We have project hosted on Github with many issues, it would be easy for us just to click one button in Issue web interface and create new branch for it to start developing.
This is not possible directly from the issue interface. I can try to provide you some workarounds and maybe start a debate why one would want this feature:
Creating branches directly on the web interface
After you've noticed that you need to start working on an issue you can just go to the repository main page (keyboard shortcut gc) and create a branch with the name you want:
Chrome extensions
If this is a must for you, you can create a chrome extension that augments the UI and creates a branch directly from the Issues WebUI using the GitHub API. There's a lot of open source extensions that augment the default WebUI.
Is it the most efficient way to start a new feature?
I think this changes from developer to developer, but having worked with GitHub for 7 years using Issues I've never felt the need for this feature because unless it's a one line change that doesn't require local testing or compilation, I still want to get down to my command line and IDE. If I have to do that, I still have to at least git fetch to get the branch I just created directly through the issue interface. If that's the case I've always preferred to just look at the issue and run git checkout -b branch-name, optionally with git push if my team needs to see the branch.
Then the issue name wouldn't normally translate to a branch name, at least I wouldn't want that. So that option to create a branch from an issue would probably need to spin out a prompt to allow me to name the branch what I wanted.
This is just my personal opinion and nothing else, hope it helps :)
GitHub finally added this feature request to their roadmap.
Summary
The branch is the first thing a developer creates when the start
working on a new issue. Creating that association makes it really easy
for someone to then follow the work happening and keep everything
connected as they take their idea to code.
Intended Outcome
We want to help developers get started on work faster and signal to
their team where to find the code changes related to an issue. It
should also be really easy to then follow development to the pull
request without the user needing to do additional work to link
everything together.
How will it work?
From the issue page, a user can quickly create a branch with an
auto-generated or custom name that becomes associated with the issue.
They can then fetch the branch and switch to it in their development
environment and further development changes (such as commits and pull
requests) are automatically associated with the issue.
https://github.com/isaacs/github/issues/1125
Nope. You can subscribe this issue.
You could accomplish this by creating a small script.
I'd start by leveraging the Issues Event webhook. This will fire a JSON payload every time an issue is opened. When the webhook fires, your script can then create a new branch using the Create a Reference API endpoint. Note: URL must be formatted as heads/branch, not just branch.
There is an app that automatically creates branches for issues. You can install it here for free: https://github.com/marketplace/actions/create-issue-branch
If you want to create the branches manually instead of automatically:
It does not enable you (directly) to click on create branch from the issue. Instead you would have to write a comment in the issue consisting of: /cib. If you do that, it automatically creates the branch from the issue.
Please note I have no affiliation with the app.
Recently I saw that Github finally added this feature to its Issues Panel.
All you have to do is navigate to an Issue on Github and scroll down to the following section:

How to completely remove an issue from GitHub?

Is it possible to completely remove an issue from the GitHub issue tracker?
No, the github API only allows you to open/close/reopen issues. Here's the Issues API docs.
You can edit an existing issue (let's say if it's a duplicate) and you can change the title, description and target milestone to be something completely different. That's as close as you can get to removing the ticket, AFIK.
Update Nov 2018: You now can delete issues if you are a owner of the repository!
See "Github - remove issues entered in error"
https://docs.github.com/en/github/managing-your-work-on-github/deleting-an-issue mentions:
People with admin permissions in a repository can permanently delete an issue from a repository.
For other people (without permission), questionto42's comment shows that you can ask to GitHub support for the issue to be deleted, as illustrated here.
At May 2018, original answer:
Three 8 years later, and closing issues remains the answer (still no deletion possible).
See "The Ghost of Issues Past", where GitHub advise to check and close:
issues opened over a year ago state:open created:<2013-01-01
the ones I'm involved with involves:twp state:open created:<2013-01-01
and those not updated in the last year involves:twp state:open updated:<2013-01-01
For posterity: Deleting issues would be a bad thing, since in general they can be targets of associations on github.
But if you are willing to sacrifice the collaboration info, here is a "whack it with a sledgehammer" approach:
Clone your original repo.
Copy your issues via the Issues API.
Delete the original repo; alternatively, chose a new name for your new repo.
Re-create a new repo based on your clone.
Re-create the issues you want to keep via the Issues API.
I imagine this could potentially lose a lot of other linking information as well such as forks, pull requests, etc.
Public feature request
I wrote to GitHub in 2014-08 and https://github.com/jdennes replied by email:
Thanks for the suggestion. It's only possible to edit/clear the issue content currently. However I've added a +1 to this suggestion on our internal Feature Request List.
confirming it was not possible.
Best workaround so far
set the title to something that will never conflict with any search, e.g. a single dot ..
This may not hide the history of your blunder entirely because of the automatic undeletable "changed the title to" comments.
make the body empty
GitHub staff has the power
If something is a security issue, contact GitHub staff, they usually reply quickly, and are able to remove issues for good as can be seen at: http://archive.is/OfjVt which has issue 1 and 3 but no 2.
You can delete the entire repo if it's really important.
Possible workaround
As of 04/2019 not all issues can be deleted current work around is to edit the issue then delete the edit history, the only downside is that the issue still exist and the old title could be seen.
You could by just asking to github to ban the user that created the issue 😁
Source: https://github.com/isaacs/github/issues/253#issuecomment-290944938
Users are unable to do this, including repository owner.
But issues can be deleted by Github support. One may contact them and request deletion. It may be delayed or refused but it is an available option that can be used.
Still impossible. Another workaround to the ones suggested in the other answers is to label the issue as "deleted" (or any other label you might fancy better), to be able to filter them out if you use the github API to retrieve them. Obviously you should use that specific label only for this purpose, setting the label when you close the issue.
You can create a new repository.
Transfer (yeah it is possible) unwanted issues to the new repository.
Then delete the new repository.