Git & GitHub Interview Question #82
How can a pull request close a GitHub issue automatically?
GitHub Collaboration, Repository Rules, Issues, Releases & Actions CI/CD Mid-Level Intermediate
Quick Interview Answer
GitHub supports closing keywords in pull request descriptions or commit messages when they reference an issue in an appropriate repository context. Common keywords include closes, fixes, and resolves.
Detailed Explanation
GitHub supports closing keywords in pull request descriptions or commit messages when they reference an issue in an appropriate repository context. Common keywords include closes, fixes, and resolves.
When the pull request is merged into the relevant default branch, GitHub can automatically close the referenced issue. Teams should use this only when the pull request genuinely completes the issue.
Code Example
# Example pull request description:
Fixes #58
# Example commit message:
git commit -m "Fix login redirect; fixes #58"