Git & GitHub Explained

At my last job I often heard the word GitHub thrown around by developers. I knew that their code was “on” GitHub, but that was just about all I knew. So when I started learning to code I quickly created a GitHub account (with my favorite username yet: gitlaura) and went through the practice exercises to learn how to use it. I started pushing whatever I was working on to my GitHub account.

Even though I was typing ‘git’ into my command line for commands like ‘git add’, ‘git commit’, and ‘git push’, I had no idea that git was separate from GitHub until recently. In fact, I assumed that GitHub somehow created that functionality on my computer.

Well, news flash: Git and GitHub are not the same. I honestly feel a little silly even sharing this with you, but I figure there must be other self-taught programmers out there who don’t understand the difference between Git and GitHub. So let me explain.

Version Control

First, let’s talk about version control.

Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. Version control is actually used throughout many business departments. For example, design teams use their own version control systems to keep track of changes to their files so that they can always go back to old versions. Even Microsoft Word and Excel allow you to keep track of changes so that you can go back to an older version if necessary.

Good version control is crucial to efficient software development, especially when collaboration is involved. Version control should allow you to revert files back to a previous state, revert an entire project back to a previous state, review changes made over time, see who last modified something that might be causing a problem, who introduced an issue and when, and recover files easily if you screw things up or lose them.

There are Centralized Version Control Systems (CVCSs) which allow users to check out files from a single, central server, such as CVS, Subversion, and Perforce. And there are also Distributed Version Control Systems (DVCSs) that allow users to clone an entire repository of code, such as Git, Mercurial, Bazaar or Darcs. DVCSs enable users to keep working if a server is down because they can keep committing and have access to the entire code base on their computer. Also, if the server dies, any client repositories can be copied back up to a new server since each checkout is a full backup of the code.

Git

Okay now back to Git.

Git is a distributed version control system (DVCS) and source code management tool. It was initially designed and developed by Linus Torvalds for Linux Kernel after Bitkeeper, another DVCS, revoked free access from the Linux Kernel development community. It was created to handle large projects, like Linux Kernel, efficiently.

Git thinks of its data like a set of snapshots. Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.

Git is local, and therefore, fast. Because all of the code history from a repository is cloned to your computer, most operations in Git only need local files and resources to operate. You don’t need to connect to another computer to work.

When you’re working on code on your local computer, you are in the working directory. You can then stage the files, which adds a snapshot of your files to your staging area. Lastly, you commit the code with permanently saves that snapshot to your directory or repository.

After you commit code to your local repository, you’ll want to upload or push your code to a server so that others can share it and you can access it even if the files on your computer are destroyed. This is where GitHub finally comes in…

GitHub

GitHub is a place to store and share code with friends, colleagues, classmates, and strangers.

Once you’ve committed code to your local repository using Git, you can then push your code up to GitHub to be saved in the cloud under your GitHub account.

GitHub makes it really easy for teams to share projects and code repositories. Anyone can easily clone your repository onto their local computer and play around with it. Then they can request to have their code, hopefully code that improves the project or moves it forward, merged with yours.

In my opinion, GitHub is like Dropbox meets LinkedIn for code. It’s actually become a sort of resume or profile for many programmers. It’s the place to store all of the great projects you’re proud of.

Summary

As you can see, Git and GitHub are very different. GitHub did not create Git and vice versa. I like to think of it like this: Git provides an incredible version control system and GitHub allows you to store that version control history in the cloud.

References:
http://git-scm.com/book/en/Getting-Started (Highly recommend reading this)
http://en.wikipedia.org/wiki/Git_(software)
https://github.com/about

Leave a Reply

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