Git Vs. GitHub: Demystifying the Differences
Git Vs. GitHub: Demystifying the Differences
Demystify the difference between Git and GitHub to better serve your source code.
Join the DZone community and get the full member experience.Join For Free
If you have ever worked with code, then you must have come across terms like "Git" and "GitHub." It is also possible that you used them as well. But do you know what exactly is Git or GitHub, and how they are different from each other?
Well, if you don’t, no worries! It’s never too late to learn new stuff, nor is it that tough in this case. By the time you finish this post, you will have a clear understanding of both Git and GitHub and how to best use them.
You may also like: Top 20 Git Commands With Examples
Version Control: Git Vs. GitHub
To understand the exact difference between Git and GitHub, you first need to know a thing or two about version control. So, what is version control?
Version control refers to a system that records changes to a file or a set of files over time, called "versions." In other words, these versions will help you track changes in your code/project and, if necessary, undo those changes as well.
This ability to be able to compare, differentiate, and revert changes between two versions of a particular project becomes extremely helpful when working on larger projects. Larger projects mean more people working on the same code, which increases the chances of a conflict. Using version control, you can easily prevent these conflicts.
This system that controls the versioning of code is called a Version Control System (VCS). For a better picture, you can think of it as a database. Within this database, the VCS takes snapshots of your entire project and stores them as versions. Now with the help of these snapshots, you can easily compare the versions and switch between them as per your needs. Check out the picture below that demonstrates the entire process:
I think now you clearly understand the concept of version control. One thing I would like to mention here is not to confuse VCS with a back-up/deployment system. VCS totally eliminates the need for changing or replacing the toolchain, unlike the back-up systems. Below, I have listed a few advantages of using version control:
- Version control creates proper workflows that help in preventing chaos among people using their own development process with different and incompatible tools.
- Each version has a description of the changes made in this version. These descriptions help in tracking the changes in the code by version.
- VCS synchronizes the versions and ensures that your changes don’t conflict with others using the same repository.
- VCS helps in keeping the history of changes as other people save new versions of your code. This history can be reviewed to find out by whom, why, and when changes were made.
- The VCS automation feature saves yours, as well as your team's, time and generates consistent results by performing testing, code analysis, and deployment whenever any new versions are saved.
So now, let’s proceed with this blog on differentiating Git and GitHub. Let's started with Git.
What Is Git?
Now that you know about version control, it will be really easy for you to understand Git. So, what is Git?
Git is a version control software that you install on your local system. For an individual working on a project alone, Git proves to be excellent software. But what if you are working on a project with a large team? All will be working on the same project but each of you will be having a different version of the same project.
Consider this scenario. You made changes in the project directory on your machine and you wanted to send those changes to your collaborators. Additionally, you wanted the changes they made to appear directly in your machine’s project directory.
When working on a project, being on the same page with your teammates is very crucial to avoid any type of conflict. So, how you will do that? Well, Git takes care of all of that, but the only condition here is that each of your team members must have Git installed on their systems. That's it.
Git also is known as a distributed version control system, which means using Git, you can push and pull yours as well as others' changes to other people’s machines, like so:
Now, using Git, you can work on the same copy as your team member. But the copy on which you will be working won’t reflect any of the changes in the main directory unless, and until, you pull your collaborator’s changes and push back your own changes.
In today’s market, Git is the most widely and popularly used modern VCS. It has also matured immensely and is a well maintained open-source project. Developed back in 2005 by Linus Torvalds, who is also the creator of Linux OS kernel, if you check the above picture of a Google Trends result, you will find that Git has continued to grow in the market since 2005.
A varying number of software projects, including commercial as well as open-source, completely rely on Git for their version control. So, how is Git different from the rest?
The major difference between Git and any other VCS like Subversion (SVN), Mercurial, TFS, Perforce, Bazaar, etc., is the way Git stores its data. In other systems, information is stored as a list of file-based changes, which is also known as delta-based version control. But in the case of Git, it stores its data in the form of a stream of snapshots of a miniature filesystem.
With Git, whenever you commit or save the state of your project, a snapshot is taken of the present file state and a reference is stored for it. If no changes or updates are done, then Git stores a link to the previous file that it has already stored. The following diagram shows how Git stores different versions:
But Git will only be helpful when you know when your collaborator’s system is turned on and is connected to the network. So what will you do when your team members are not online? In these situations, a third party having an identical copy of your project, from where you can easily push and pull the changes, will come in handy.
Well, you will be glad to know that this is what GitHub it for! In the next section of this blog, we will explain this further.
What Is GitHub?
As mentioned earlier, Git is a version control system that tracks code changes, while GitHub is a web-based Git version control repository hosting service. It provides all of the distributed version control and source code management (SCM) functionalities of Git while topping it with a few of its own features. It is heaven for developers — a place where they can store their projects and connect with like-minded people. You can think of it as a “cloud for code."
So basically, GitHub is a place where you can store identical working directories or repositories. It literally is a hub for the Git repositories in which you can use simply by creating a free account on the GitHub. These accounts come with abundant storage space where you can store your repositories and build a proper profile that holds all of your most important projects.
By default the repositories are public and everyone can see your code. But, if you want, you can make it private as well. And, again, GitHub works in collaboration with Git.
While Git is a command-line tool, GitHub is a web-based graphical interface that provides you with access control, basic task management tools, along with several collaboration features.
Moreover, GitHub can host your project’s source code in various programming languages and keep track of changes made to every iteration. GitHub’s functionality doesn’t end here. It provides the following three extraordinary features that make it even more powerful:
- fork: Or commonly known as forking. This is copying a repository from one user’s account when you don’t have the right access to it. So, you can just copy it and modify it under your own account.
- pull: When you have made changes to a piece of code that you copied and want to share with its original owner, you can then send a notification called a “pull request” to them.
- merge: Now, the original owner of that now-modified code, if they find your changes relevant, can merge the changes made in your repo with the original repo, in just a click of a button.
If your pull request is accepted by the owner, then you get credit on the original site and it shows up in your user profile. It is kind of like a resume that helps the GitHub project maintainer determine your reputation. So, the more people and projects on GitHub, the better the ability for a project maintainer to see the potential of their contributors. This encourages young developers and projects to grow more in the industry
Now that we've defined Git and GitHub, let's summarize the basic differences between the two.
Git Vs. GitHub
|1. It is a software||1. It is a service|
|2. It is installed locally on the system||2. It is hosted on the Web|
|3. It is a command-line tool||3. It provides a graphical interface|
|4. It is a tool to manage different versions of edits made to files in a git repository||4. It is a space to upload a copy of your Git repository|
|5. It provides functionalities like Version Control System Source Code Management||
5. It provides functionalities of Git like VCS and Source Code Management, as well as adding few of its own features
This concludes our post on Git versus GitHub. We hope you enjoyed reading and learned something new!
[DZone Refcard] Getting Started With Git
Published at DZone with permission of Swatee Chand , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.