Closing issues in GitHub using pull requests is a valuable skill that enhances your workflow's tidiness and automation. This guide will explain how to use the GitHub feature that allows for closing issues directly from pull requests and how you can manage this process via Graphite's PR inbox for a more efficient experience.
Understanding the process
GitHub provides a feature where you can close an issue directly from a pull request (PR) by using specific keywords in your PR description or in individual commit messages. This helps maintain a clear relationship between code changes and the issues they address.
Keywords to close an issue
The following are the primary keywords that you can use within a PR's description or in a commit message to close an issue:
- close
- closes
- closed
- fix
- fixes
- fixed
- resolve
- resolves
- resolved
When you use these keywords followed by the issue number (e.g., closes #123
), GitHub will automatically close the issue once the PR is merged into the default branch (usually the main
branch).
How it works
- Create a pull request: When you're ready to merge your changes that address an issue, you can create a PR.
- Include a keyword and issue number in the PR description: For example, "This PR fixes #45". You can also use these keywords in a commit message.
- Merge the PR: Once the PR is reviewed and approved, merging it into the main branch will automatically close the associated issue.
Practical example
Let's say you have an issue in your GitHub repository described as "Fix login bug". The issue number is 102. You make the necessary code changes and are ready to submit your PR.
- Branch and commit your changes: You would typically create a branch (e.g.,
bugfix/login-issue
) and commit your changes. - Push and create a PR: Push your branch to GitHub and create a PR against the main branch.
- Use a keyword in your PR description: In the PR description, write "This PR resolves #102".
- Review and merge: After review, once you merge this PR, GitHub will automatically close issue #102 as resolved.
Integrating with Graphite's PR inbox
Graphite's PR inbox acts as a centralized hub for your pull requests, helping you manage and organize your PRs effectively. Here’s how you can use Graphite in conjunction with GitHub:
- Organize your PRs: Use Graphite's inbox to organize PRs into categories like "Closes specific issue," "Approved," and "Merging."
- Link PRs to issues: While Graphite does not directly close issues in GitHub, it helps you monitor which PRs linked to issues are about to be merged. This is handy, especially when dealing with multiple PRs that might close several issues upon merging.
- Custom filters and sections: You can customize your inbox sections in Graphite to track PRs that are linked to closing issues, ensuring you never lose sight of critical updates that will impact your project's progress.
By combining GitHub's issue-closing feature with Graphite's organizational tools, you can streamline your workflow, ensuring that nothing slips through the cracks. This integration not only simplifies management but also enhances team collaboration by keeping everyone updated on the status of both PRs and issues.