Wednesday 21 March 2012

Fun with github

A while ago I was working at home. I was working with Ștefan Rusu's excellent aws2js npm module for wiring up nodeJS servers to AWS. I wanted to make a small change, so I forked his github repo, made my changes and sent him a pull request. A very short while later he took my changes, fixed my mistakes, and the outcome went into the next release of his module. A great experience for me, a good advert for the the github way of collaborating.

Today I'm working on the same code base and I want to make another small change to Stefan's code. So, the tasks I need to accomplish go something like this

  1. Check out my fork
  2. Pull all the changes from Stefan's master to bring myself up to date
  3. Check that into my repo
  4. Change whatever I want to change
  5. Check the changes into my repo
  6. Give Stefan another pull request.

There's a further complication which is that I'm working in the office today, so I need to setup my work machine to be capable of checking into my github repos. This blog is an aide-memoire for me about that last issue and steps 1 to 3.

To get my work machine setup, I need to something like

cd ~/.ssh

rm id_rsa id_rsa.pub           # or stash them somewhere safe to put back later

ssh-keygen -t rsa -C "my-email@my-domain.com"
                               # and hit return to the various questions

ssh-add ~/.ssh/id_rsa

vi ~/.ssh/id_rsa.pub           # and copy the contents


Then I log into my github account, "add an SSH key", and paste the copied file contents.

Now for steps 1 to 3:

# 1. Check out my fork

git clone git@github.com:dcleal/aws2js.git

# 2. Pull all the changes from Stefan's master to bring myself up to date

git remote add upstream git://github.com/SaltwaterC/aws2js.git

git fetch upstream

git merge upstream/master

# 3. Check that into my rep

git push origin master

No comments: