Introduction to Git and GitHub: How are they different? What do they do?
What is the difference between Git and GitHub? Simply put, Git works on your local repository, and GitHub acts as cloud storage for the remote version of that repository. If you’ve ever used Dropbox or Google Drive on your desktop, phone, or tablet, you understand how a cloud-based system can back up your files. GitHub does a similar thing for Git repositories.
Already know the difference? Click here to get started tracking your project today with basic Git commands.
What is Git?
Git is a programme which allows you to track changes to files over time, without having to ‘Save As’ over and over again. You can access all different versions of those files for as long as you’ve been tracking them.
Consider your CV: most likely, you have played the ‘multiple versions’ CV game where you have to ‘Save As’ in Microsoft Word (or similar) with different names, over and over again, as you add different sections, make different versions, or simply update it with new information. Doing so can work if you’re strict about how you save and you’re only working with a minimal number of documents.
However, in the computing world, engineering teams are working on hundreds or thousands of documents for one project, and using ‘Save As’ is just not feasible. Eventually, someone will lose a file or someone will have to manually combine files that have different changes made, or even worse: you’ll accidentally use an old file because it’s not clear which one is the ‘main’ one or the most recent one. Git has been designed to solve this problem.
As you work on files and folders locally, when you’re happy with them you ‘commit’ them to Git: that is, save that as the latest version. Git then keeps a record of all the changes made in that folder: from renaming files to adding/deleting lines, and more. The sum of all these files, tracked changes, different versions, etc. is referred to as a Git repository. In general, you will have one repository per project.
What is GitHub?
GitHub is basically the online cloud/storage system for Git repositories. By linking up your local repository with an online (GitHub) repository, you can easily keep all versions of your project online. This not only provides you with a backup in case your local computer dies, but it also allows others to view and contribute to your code. Similarly, you can access thousands of other online repositories, view issues, and work on the code for them too.
Are changes made in Git automatically available on GitHub? No. There is a special procedure for downloading files/changes (known as ‘pulling’) and for uploading files/changes (known as ‘pushing’) to GitHub or any other remote or linked repository. Unlike some cloud storage systems such as Dropbox, which automatically updates itself as you change files, GitHub will only make changes in the cloud once they’re approved or pushed manually.
Keep a look out…
This week I’ll be adding a post covering the basic workflow of Git for your own project, based on your own computer. From there, I’ll be adding a few practice exercises so you can start using Git ASAP in your coding journey.
UPDATE: Basic Workflow Tutorial for Git/GitHub has now been posted! Check it out to get working with these two today.