Pair Programming with Github
Arguably one of the best aspects of software development is the ability to work on the same project, remotely, without emailing or other archaic forms of file sharing. How you ask? Github of course.
Instead of covering the basics of getting an account or forking a repository, I’ll go over the terminal commands for working on a branch and pulling changes made by collaborators in your repository. This tutorial starts after you’ve already forked, cloned, added collaborators to your repository, and cd’d into your directory.
Generally speaking, you should never work off the master branch. Instead, create your own branch and check it out. This can be accomplished in one line.
git co -b angela
The above creates a branch called ‘angela’ and simultaneously checks it out (co is short for checkout, -b creates a new branch). Each contributor in the repo should always be working on a different branch.
Once you’ve made changes on your local branch and are ready to post them to Github, the following commands should be executed in order:
git add .
git commit -m "your comment about the commit"
git co master
git merge <branch name from which you made changes>
git push origin master
The above sequence of commands takes all changes and:
- stages them
- commits them
- pushes to your remote branch
- merges the branch changes to the master
- pushes to your remote master
The other very essential piece of pair programming is pulling the changes that have been made by other collaborators, which they’ve already pushed to the remote master. Here’s the sequence we’ll use to get the changes down to local:
git co master
git co <branch you plan to work on locally>
git merge master
The above does the following:
- pulls down the changes from remote master to local master
- changes to local branch used for making changes
- merges changes from local master to local branch
Happy pair programming!