GitHub supports special keywords that allow issues to be closed automatically when a pull request or commit is merged into the default branch, such as main. This functionality helps maintain cleaner workflows and better issue tracking.
Common Keywords for Auto-Closing
The following keywords, when used in a pull request description or commit message, will automatically close the referenced issue once the code is merged:
• fixes #1
• closes #1
• resolves #1
Example:
1 | Fixes #42 by updating the caching strategy. |
Multiple issues can also be referenced in the same statement:
1 | Closes #5, resolves #7, and fixes #9. |
Referencing Without Closing
To create links between issues and pull requests without triggering auto-close, use general references such as:
• Related to #2
• See also: #3
• Blocked by #4
These references do not close any issues but appear in the sidebar for better visibility and traceability.
Notes on Behavior
• Auto-closing only occurs when the pull request is merged into the default branch.
• Keywords must be in the pull request description or the commit message that is part of the merge.
• Comments or discussion threads do not trigger automatic closing, even if keywords are present.
Summary
Using GitHub’s built-in keyword system enhances automation and keeps issue lists up to date with minimal manual intervention. Including the appropriate keywords ensures that completed work is properly tracked and linked.