Getting to grips with GitHub
As promised in my previous blog post I will be taking a look at GitHub. Like I mentioned before I have heard of GitHub and understand its purpose but that’s about it, I find the concept slightly confusing, so hopefully I will have a better understanding when I finish researching and trying out GitHub.
What is Github?
Well one thing I do know is that it’s a repository for the version control system Git. Here are the definitions given on the Github Homepage:
Git is an extremely fast, efficient, distributed version control system ideal for the collaborative development of software.
GitHub is the best way to collaborate with others. Fork, send pull requests and manage all your public and private git repositories.
Ok so those two definitions make sense but they don’t give any insight on how to use them, but I figure the best way to get to grips with something like this is to try it out. Luckily there are plenty of resources available for newcomers. I’m going to stick to the basics as I believe that’s all I need to get up and running and I can learn more as I need!
There are a few advantages to using Git over SVN
- You can work offline in Git, although obviously push or pull to a remote server will not work
- Git is a lot faster than SVN
- Git takes up a lot less space than SVN
- Finally you can push and pull to more than one server
How to set up Git
So obviously since GitHub relies on Git I better go and download it. You just install it like any other application, but it doesn’t to act like any other application, there is no GUI, it relies on the command line, or terminal to us Mac folks, hardcore! This didn’t put me off as I knew the GitHub team had created a very nice Mac App with a very nice GUI, which as far as I can tell offers most of the features/functionality I need.
I will cover this in more detail as I am not a huge fan of using Terminal (yet). I am going to use the Mac App for a while but I wanted to get Git setup and ready to use with GitHub incase I change my mind!
So once I installed Git I wanted to check if the install went ok, the easiest way to do this was to open Terminal and type in the following:
This is what I saw:
The most commonly used git commands are: add Add file contents to the index bisect Find by binary search the change that introduced a bug branch List, create, or delete branches checkout Checkout a branch or paths to the working tree clone Clone a repository into a new directory commit Record changes to the repository diff Show changes between commits, commit and working tree, etc fetch Download objects and refs from another repository grep Print lines matching a pattern init Create an empty git repository or reinitialize an existing one log Show commit logs merge Join two or more development histories together mv Move or rename a file, a directory, or a symlink pull Fetch from and merge with another repository or a local branch push Update remote refs along with associated objects rebase Forward-port local commits to the updated upstream head reset Reset current HEAD to the specified state rm Remove files from the working tree and from the index show Show various types of objects status Show the working tree status tag Create, list, delete or verify a tag object signed with GPG
Now that Git is setup I need to create an account on GitHub.com. The next step is to set up SSH keys, to allow my computer and GitHub to transfer data through a secure connection. There is a great help section provided on the GitHub site which I found very useful.
Using the GitHub App for Mac
I decided that I would give the GitHub application a go and see how I get on with it, I admit I have a thing for well designed apps!
Installation done, account details entered. Now to create a Repository for my Major Project. It couldn’t have been any simpler, all I had to do was click the New Repository button on the lower left and up popped the window that you can see below. I entered in the name and located the folder I wanted to use, leaving out the description which is optional and can be added at a later date. I unchecked the ‘keep this code private’ box as I will not be paying for an account.
I was then taken back to the main window and the repository was now added to the list. Clicking the arrow on the repository revealed the history, changes, branches and settings.
Above you can see the history relating to the repository in this case the addition of a style.css file, a README file and a rule to ignore .DS_Store files which flag up to be committed when a new folder is created.
When any changes have been made to any of the files on the MajorProject folder, it will flag them here and ask me to commit them. I have two options, I can go with commit (offline) or commit and sync which pushes the changes to GitHub.
Thoughts on the GitHub App
I’m sure many people out there would wonder why I would want to use an application which surely would be a much slower way of doing things, but that’s the problem, for me using the application would be much quicker than having to type out commands that I have to keep looking up online. I’m not saying I will never use Terminal but for now I am happy to learn all of the fundamental concepts and get used to working with a different mindset.
The app itself is excellent in terms of the UI, it’s gorgeous. It’s very straightforward to use and the designers have done a great job of creating content focused layouts and a well thought out task flow, between all of the key features like history, commit and branches. The only negative is that it is quite buggy, although that could be be due to me doing things wrong. I do think error messages could be a little clearer in describing what went wrong, but overall it’s very impressive and will do the job perfectly for me until I am ready to jump ship and use Terminal.
To Sum Up
I am glad that I took the time to play around with GitHub as I have a much better understanding of how everything works (committing changes, pull requests etc.) and the fundamental concepts behind version control and how beneficial it will be for me to use for my Major Project in terms of having an online backup, being able to roll back any changes and the option to use people’s pull requests, if they wish to contribute to what I’m working on. I can definitely see myself using GitHub in the future for other projects, the only thing stopping me before was that I thought it would negatively impact on my workflow, but this is definitely not the case.