Convert a GitHub Issue Into a Pull Request
A little-known-feature of the GitHub API is the ability to attach changes to an issue, converting it into a pull request. The hub command, a wrapper around
git that makes it more GitHub aware, allows you to easily do this.
hub pull-request -i 384 -b bkeepers:master -h bkeepers:branch-name
-iis the GitHub issue number
-bis the base, or where you want to send the pull request, with
bkeepersbeing the owner of the repository.
-his the head, or the branch where your changes live.
I put together a quick (crappy quality) video showing how this works.
My workflow lately has been something like this:
1. Create a milestone in GitHub Issues for the mini-project I am working on
2. Create Issues for the features I can foresee and begin discussions
3. Work on the code for an issue in a branch
4. Push the branch and convert the issue into a pull request with the command above
This workflow is also great for handling bugs, where someone likely opened an issue to report it, you create the fix in a branch, attach it to the issue, and then close it by merging the pull request.
The biggest caveat with this approach is that it does not work well for experimental code. There is not undo button for converting a pull request back into a plain ol’ issue, nor is there a way to replace the pull request with a different one. So if you convert an issue into a pull request, and then decided you don’t like the implementation, you have to close the issue, burying the discussion around it.