Closing multiple issues in Github with a commit message

GithubIssue Tracking

Github Problem Overview


I know you can close issues by putting closes #1 or fixes #1 in the commit message. What is the best way to close multiple issues in the same commit message?

Also, it appears that using fixes rather than closes doesn't create a link from the commit message to the issue, but it does close the issue. What's up with that?

Github Solutions


Solution 1 - Github

Closes #1, closes #2, closes #3; rest of commit message.

The closes clauses can be anywhere in the message and fixes is a valid synonym:

This fixes a memory leak in foo() that closes #4,
also fixes #5 which is a duplicate.

The following used to work, but nowadays only references issues #2 and #3.

Closes #1, #2, #3

Solution 2 - Github

The answer and a comment to that answer mention the following format:

> Closes #1, closes #2, closes #3; Actual commit message

If I had a project worth participating in and someone sent a pull request with such commit messages, I would refuse the pull no matter how beautiful the code was.

It is possible this is just a matter of my personal preference and will end up beaten to the very ground by people used to compact commit messages that clutter up Git history summaries, but I would much rather see commit messages with the format:

> Summary of the change made. > > Fixed following bugs:
> * Modified error loader, fixes #1
> * Returned a nonstale pointer, fixes #2
> * Applied new graphics to gui elements, closes #3

He asked for the best way to close multiple issues.

Also note that if you push the commit with the message to any other branch than the current default branch of your repository, the issues will only be referenced. Pushing the commit to the main branch will close the issues. See: https://stackoverflow.com/questions/13977161/link-to-github-issue-number-not-working

Solution 3 - Github

Note that, since January 2013, "Closing Issues via Commit Messages" has changed:

Now when you enter "Fixes #33" in a commit message, issue 33 will only be closed once the commit is merged into your default branch (usually master).

> This is super useful because it means the issue's open / closed status will map to your default branch.
If the bug isn't fixed in your default branch, the issue will remain open.
Once the commit with the fix is merged into your default branch the issue will be automatically closed.

> You can use any of these keywords to close an issue via commit message:

close, closes, closed, fixes, fixed

As illustrated by the question "Closing a GitHub Issue while on a different branch", this causes some confusion at first.

Solution 4 - Github

Here from Github self a documentation: Linking a pull request to an issue

Resolves #10, resolves #123, resolves octo-org/octo-repo#100

Screenshot from GitHub Documentation

Solution 5 - Github

"Closing issues using keywords" is a document from GitHub that describes how to close issues, tags and how to close multiple issues.

To answer your questions the answer from GitHub is:

> Closing multiple issues > > To close multiple issues, preface each issue > reference with one of the above keywords. You must use the keyword > before each issue you reference for the keyword to work. > > For example, This closes #34, closes #23, and closes > example_user/example_repo#42 would close issues #34 and #23 in the > same repository, and issue #42 in the "example_user/example_repo" > repository.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRayneView Question on Stackoverflow
Solution 1 - GithubJakob BorgView Answer on Stackoverflow
Solution 2 - GithubJNissiView Answer on Stackoverflow
Solution 3 - GithubVonCView Answer on Stackoverflow
Solution 4 - GithubNo Name ProView Answer on Stackoverflow
Solution 5 - GithubVlad BezdenView Answer on Stackoverflow