Using Hub for faster Open-Source contribution
Ever wondering how you can easily fork and contribute to an Open-Source project without forking a repository manually in your browser? Then you should have a look into the hub gem.
Hub is a command-line wrapper for git written by defunkt. With it, you can easily create forks of repositories, making pull requests, and get code from other forks with no problems. If you are a maintainer of a very popular repository like twitter bootstrap with over ~23k forks, this tool makes your life a lot easier.
Update: hub is now available as precompiled binaries - so you don’t need it compile with go
Grab the latest hub release for your system and player into your bin path.
Workflow to get things done
What I normally do when using Open-Source technologies like the Foundation Framework is trying to give something back. For example by improving documentation, reporting bugs, or solving problems.
First of all let’s get the code:
$ hub clone zurb/foundation-sites Cloning into 'foundation-sites'... remote: Counting objects: 81224, done. remote: Compressing objects: 100% (28/28), done. remote: Total 81224 (delta 10), reused 0 (delta 0), pack-reused 81195 Receiving objects: 100% (81224/81224), 112.63 MiB | 1.11 MiB/s, done. Resolving deltas: 100% (48423/48423), done. Checking connectivity... done.
Now let’s make a branch for fixing some documentation issues:
$ git checkout -b readme-fixes
Now you make your changes and run a
git commit -m "Fixed documentation" and you are ready to fork the repo:
$ hub fork
Now you need to push the changes to your remote and open a pull request:
$ git push -u wikimatze readme-fixes $ hub pull-request
That’s it. If you want to see a list of open issues, you can use the following command:
$ hub browse -- issues
This will open the issue site in your browser. In our case this would be https://github.com/zurb/foundation-sitesissues.
If you want to see a list of pull-requests, just pass the
$ hub browse -- pulls
Remember your username and token
Go to your github token settings, generate a fresh one and
put them into
--- github.com: - user: wikimatze oauth_token: <TOKEN>
Now you don’t need to type in your username and password everytime.
The idea for this blog came out of my first remote paring session with my friend @_ZPH where I wanted to show him this gem but wasn’t able to explain him the work flow. So this little snippet is a reminder for him and me.