Today, another pull-request flew in, enhancing the picoReflow software stack with MAX6675 compatibility. Git and github are great tools for open collaboration but it takes some time to get used to them. Of course, the github auto-merge feature is great and works pretty reliable, but I still prefer to review and test PR's locally on the commandline, before actually merging them.
Github also offers some command line foo for this, as you can see in the screenshot above but I'd like to use this opportunity to share another way how to test, handle and merge github pull requests even more easily and comfortably, in case you're new to git/github and don't know about this yet in a real-world, step-by-step example.
Just go into the directory where you store the git repo you have received a pull request for and open .git/config in an editor. You'll find a section that looks like this (with your repo names of course).
[remote "origin"] url = firstname.lastname@example.org:apollo-ng/picoReflow.git fetch = +refs/heads/*:refs/remotes/origin/*
We just have to add another fetch target so our git knows where to fetch pr's from github:
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
Now the section should look like this.
[remote "origin"] url = email@example.com:apollo-ng/picoReflow.git fetch = +refs/heads/*:refs/remotes/origin/* fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
This has to be done only once per project/repo. Afterwards you can just start with Step 1:
When receiving a new pull request on github, you'll get a notification with the pull request's id, like this:
Now we just have to fetch from origin to see if it pops up:
$ git fetch origin From github.com:apollo-ng/picoReflow * [new ref] refs/pull/7/head -> origin/pr/7
Good, PR #7 is here and we can just switch over to it (checkout):
$ git checkout pr/7 Branch pr/7 set up to track remote branch pr/7 from origin. Switched to a new branch 'pr/7'
Review and test the new code.
Once testing is finished and everything seems to be in order, we merge the pull request into the branch we want, in this case the master branch, so let's checkout master:
$ git checkout master
Finally we merge the pull request into the master branch and since github already told us that it could merge the PR automatically, we don't expect to be confronted with any merge conflicts:
$ git merge pr/7 Merge made by the 'recursive' strategy. config.py.EXAMPLE | 3 +++ lib/max6675.py | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/oven.py | 20 ++++++++++++++++++-- 3 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 lib/max6675.py
Now we just have to push it back to github which will automagically mark the pull request as closed/merged and notify the pull request initiator.
$ git push
Done. Easy, right?