Git, GitHub and GitLab. Are they all the same thing?
A few years back when I got serious about learning to program to become a software developer, I remember hearing about version control and getting really confused about git and GitHub (one can add GitLab to this list also!). Are they the same thing? Eventually, I figured it out but this past week in a conversation with a coworker, who is interested in getting into software development, I noticed that they also were confused about this so I decided to write about it.
Version control
Version control systems do exactly what their name says: they control versions of your software. If you are just starting and all you build is simple programs with dozens of lines, using a version control sounds a bit overkill and unnecessary. And it might be!
Now, let’s say you build a web page: it has some html and css. You spend some time tweaking the colors, fonts, font size and finally get to a point where you are ok with the result. This is saved locally and only you can see it. Next day you take another look and decide you want to try a different colour palette, font face, etc. You make all those changes and now you lost yesterday’s version. To keep the two versions you might want to save a copy of the file and name it like “my_webpage_version1.html
” before you start making the changes, for example. But this approach is only practical on very small projects. Imagine if your changes affect multiple files or even worse, you decided to try yet another version with a third combination of colours, fonts, etc. It’s impractical to manually keep track of all these versions. This is why using a version control system can be really helpful.
Git
Git is currently the most popular version control system. It’s a system that you download and install on your computer and interact with it via command line. Git has its own set of commands and it may take some time until you get comfortable with them but for the very basic functionality you only need a handful of commands (I wrote here about the commands I use most often - there aren’t really many of them!). And now with git, you create a commit for that first version of the web page. Creating a commit is like adding a bookmark or taking a snapshot of the file as it is at that moment. Then you can continue and make more changes, take another “snapshot” (make another commit) and so on. When you want to get back to the first version, you just to go back to that first commit, but your other commits are all safely saved.
I know this all sounds like almost the same thing as saving file versions before making changes but trust me, this is way more efficient. There’s a leap of faith required here. Trust me on this.
Now, let’s say you want to share your webpage with your friend Hermione and get her opinion on which version she likes best. Remember, this web page is only some local files on your computer. The different versions are all saved locally, in what in “git speech” we call a repository (think of it as a folder - it’s a bit more complex than this but for now thinking of it as a folder is ok). Should you email her these multiple files? What if you have images also? Share the whole repository via a service like Google Drive?
What if you could send this bundle to some location where Hermione can access it and using git, also toggle between the multiple different versions (commits)?
Hmmmm… ?
GitHub and GitLab
GitHub and GitLab are online services that keep a remote version of your repository so the files can be easily accessed by other people. I think the confusion comes from these services also being called “git something” and the fact that they operate with git commands as well. Think of them as “a place to share your programs.”
GitHub is very popular among open source users and I would say the most popular of the two but they both have the same general purpose.
So now, you create an account on GitHub or GitLab and upload your repository there using git commands. From now on this is the “remote” version of your files/repository. You tell Hermione what’s your repository’s url and she can, using git, download it (or in “git speech”, clone it) on her computer and check out all the different versions and give you some feedback.
To sum up:
This whole process uses git
as a system to keep track of the various commits and to manage the local and remote versions of your repository. GitHub and GitLab are the hosts of the remote version.
I hope this helps to clarify the difference between git, GitHub and GitLab. ?
Some notes:
- GitHub also has an interactive user interface but I never used it so I can’t speak about it. Using the command line is the most common way to use git.
- this article helps you get started with git and GitHub
If you found this helpful, let me know on [X](https://x.com/Flavia_SBastos) or share this article!
The post Git, GitHub and GitLab. Are they all the same thing? was originally published at flaviabastos.ca