fix fetching from and pushing to GitHub remotes

See the first commit message for details.

The code (inasmuch as it is copyrightable) is copyright my employer, Facebook, which has agreed to license it under the GPLv2.