gh: Backport changes from gh master

Cherry pick https://github.com/jingweno/gh/compare/16fbeef...f324a83. See https://github.com/github/hub/pull/544