You close an issue automatically by writing a closing keyword followed by the issue reference in the pull request description or in a commit message, for example Closes #42. When the pull request is merged into the repository's default branch, GitHub closes the linked issue for you. These GitHub closing keywords link the work to the problem it solves and keep your issue list honest without manual cleanup.
The link also works in the other direction: the issue shows the pull request that fixed it, and the pull request shows which issues it will close. Reviewers can see the intent of a change at a glance.
GitHub scans the pull request description and the commit messages for a keyword followed by an issue reference. The supported keywords are:
| Keyword forms | Meaning |
|---|---|
close, closes, closed | The change closes the issue |
fix, fixes, fixed | The change fixes the issue |
resolve, resolves, resolved | The change resolves the issue |
Keywords are not case sensitive, and a colon after the keyword is allowed, so Fixes: #42 works too. The keyword must be directly followed by the reference. A sentence such as "this is related to #42" only creates a plain cross-reference and never closes anything.
The issue is closed at the moment the pull request is merged, not when it is opened or approved. If the pull request is closed without merging, the issue stays open.
The most common place is the pull request description. Put each keyword on its own line so that it is easy to read and to edit later:
When you save the description, GitHub shows the linked issues in the Development section of the right sidebar. If they are listed there, the link is active. If they are missing, the keyword was not recognised, usually because of a typo or a missing reference.
You can also link an issue by hand: open the Development section of the pull request sidebar and pick the issue. This is useful when you forgot the keyword. Removing the link from the sidebar cancels the automatic close.
Keywords in commit messages work as well, as long as the commit ends up in the default branch through the merge:
Keep in mind how the merge method changes what GitHub sees. With a merge commit or a rebase merge, the individual commit messages reach the default branch. With a squash merge, the commit messages are combined into one new commit, and the keyword is kept only if it appears in the final squash message or in the pull request description. Putting the keyword in the pull request description is the safest habit.
For an issue in a different repository, write the owner, repository name and number:
You need write access to the other repository for the link to close the issue. A full issue URL also works, for example Closes https://github.com/octo-org/billing-service/issues/42.
Each issue needs its own keyword. This is a very common mistake:
Only #42 is closed here. The other two are just mentioned. Repeat the keyword for each one:
Or use one line per issue, as shown earlier. Both forms close all three issues when the pull request is merged.
If a linked issue stays open after the merge, check this list:
main). Merging into a release or feature branch does not close anything.Some teams change the default branch while a long-running branch is open. If your project releases from a different branch, either change the default branch setting in the repository or close the issues manually when you ship.
A closed issue can be reopened at any time from the issue page, and an open issue can be closed with the Close button without any pull request.
If you do not want an issue to close, describe the relationship in words, such as "Part of #42" or "Related to #42". The reference creates a link in the timeline but never closes the issue.
No. GitHub reads the description body and the commit messages. Put the keyword in the description.
Not automatically. The keyword takes effect only when the pull request is merged into the default branch. Close the issue by hand or merge the work into the default branch.
No. The close happens only at merge time. Approval and passing checks have no effect on the linked issue.
Closing keywords in issue comments do not close other issues. They are meant for pull request descriptions and commit messages that reach the default branch.
Write Closes #42 (or Fixes, Resolves) on its own line in the pull request description, and the issue closes when that pull request is merged into the default branch. Repeat the keyword for each issue, add the repository name for issues elsewhere, and check the Development sidebar to confirm the link before you merge.