Tuesday, September 6, 2016

Simplifying your github workflow with "hub"

As a support engineering / software maintenance engineer, I spend a lot of time looking at code, reading code, searching code, etc. So needless to say I have a few git repos's sitting arround. 

In most cases, I use these repositories to help me understand errors, or issues that customers see when using a product or library, that I am supporting. However in some situations, the problems once identified are simple to fix, it becomes time for me to change hats and become an contributor.

In most cases contributing its a pain because it involves understanding parts of the SCM (git) tooking that can be difficult to understand (when your first getting started). Depending on the project, contributing, or the workflow in how you provide contributions to the project can be "challenging". Luckily services like github have arisen to make the sharing / hosting of OpenSource projects simple. They have also worked to make "contributing" to projects simple (however these efforts of go with out praise).

One such example is github's invention of the "pull request". While this is a source control concept for "git", however its workflow definition has fundamentally altered, how contributions to projects work because it defined tooling to unify and simplify the process of contributions.


One of the complications with the "pull request" is that it, with out "sevice tooling" (Github) you are more or less providing "patches" that have to be manualy managed. The biggest complication caues by this "sevice tooling" (Github) is that you have to use the "web ui" to create / submitt a PR.

Not any more. With "hub" you can remove this complication, and move back to the terminal.

To get started you will need to install the "hub tooling", in my case on fedora I can just run.
sudo yum install hub
I can then use the use hub like 'git'.
hub clone https://github.com/openshift/openshift-docs
cd openshift-docs/
Except now, I have new options that integrate directly with the github service.
hub fork
git remote -v
From here on out, most of the "contribution process" is likely the same as what you do in for any git project. Branch -> Modify - > Commit - > Push.
git checkout -b typos
< make changes > 
git add install_config/install/prerequisites.adoc install_config/install/disconnected_install.adoc
 

<confirm changes> 
git diff master
git status
git commit -m "fixing typos"

git push <GITHUB_USER> typos
With you changes now in your "fork" and "feature branch" you can switch back to hub to complete your PR and contribute to the project.
git pull-request
  •  Note: you need to ensure that you setup your github ssh key, or you set on your git configuration:

    git config --global hub.protocol https