Creating a clear and detailed pull request description is essential for effective code review and collaboration. Here’s how you can use ChatGPT to help draft your PR descriptions efficiently.
Generate a Git Diff
First, generate the diff between your feature branch and the main branch. Save this diff to a file or copy it to your clipboard.
# Save to a file
git diff main...feature-branch > changes.diff
# Or copy to clipboard (macOS)
git diff main...feature-branch | pbcopy
Use ChatGPT to Draft the Description
Open ChatGPT and start a new conversation. Paste the git diff output into the chat and ask ChatGPT to help summarize the changes and draft a PR message.
Here’s a suggested prompt:
I've just made some changes to my project and
have generated the git diff for these changes.
Could you help me write a detailed GitHub PR
description based on this diff?
Here is the git diff output:
[insert git diff output here]
[Additionally, paste the template for the PR description here if needed]
Review and Edit the Generated Description
ChatGPT will provide a draft PR description. Review the message to ensure it accurately reflects your changes. Make any necessary edits to clarify the context, purpose, and impact of your changes.