Intro to Git

During the lunch and learn at KScope15 we talked a little about using open source projects as a way to learn/teach programming concepts.  There was a little confusion about Git and GitHub so I thought I’d put up a short post with some resources.

I don’t claim to be a Git guru by any means, this is intended to be a high level introduction.  I have linked several resources at the end for those who want to dive deep.

Git, a Distributed Version Control System (VCS)

You may be familiar with the typical VCS which has a centralized shared repository.  You checkout a copy of the code, work on it, then check it back in.  Everyone works from the same central repo.

Git is different.  Think of it as having your own personal VCS built into your local work-space.  You still check code in and out, branch, merge and commit changes; but instead of locking files on a remote system somewhere, you merge your local VCS into a shared remote repo when ready.  You have the advantage of being able to make multiple frequent commits locally and only push to the central repo when you want your changes merged into the product.  Your work doesn’t impact others till you make the push.

There are many great features in Git, but for me it’s the distributed functionality that makes it awesome.

When your central repo is unreachable (Network/internet issues, server down or system patches;) using a traditional VCS your developers are not able to commit changes till the problem is resolved.  They can continue to work, but run the risk of not being able to roll back to a ‘working’ point in the code.

With Git your developers continue to work making frequent commits; they can rollback, branch, merge and shelf changes as needed.  When the issue is resolved they pull the current state down, merge their changes and push the merged changes back up.

As an added bonus, you can push your changes to multiple remote repos.  You can push and pull from an internal company repo as well as a remote hosting service such as GitHub or BitBucket.

Remote git hosting services

A remote git hosting service is basically a place where you host a Git repository.  Similar to how you would create a Git repository on an internal server, you can create the same repo on one of these services.  Once the repo is created at your chosen host, you pull and push to it the same as an other repo.

A common misconception is that GitHub is Git.  GitHub is probably the most popular of the many remote git hosting services but it is not Git.

The two I’ve used the most are GitHub and BitBucket.  Both offer a very comparable set of services; issue tracking, pull requests, team collaboration features and others.  GitHub tends to be more popular, especially with the open source projects; BitBucket gives you private repositories in the free level.

I would recommend either one, take your time to see which fits your needs better.  If you have a service you like better please leave a comment.

Want to learn more

There are a ton of resources to help you become an expert, here are a few I’ve found.  If you have a great one, leave a comment.

Git resources:

Remote git hosting services:

Leave a Reply

Your email address will not be published. Required fields are marked *