.Git Is Not GitHub or GitLab. Here's What Every Developer Should Know

Imagine you're working on an application. You make a few changes, fix some bugs, add a new feature, and suddenly something breaks.

You try to figure out what changed, but you don't remember which files you modified.

Now imagine working on the same application with five other developers. Everyone is making changes, adding features, fixing bugs, and pushing code.

How do you keep track of all these changes? How do you avoid overwriting someone else's work? And what happens when a new change breaks something that was working perfectly yesterday?

This is exactly why we need Git.

If you've ever wondered what Git actually does, or why developers keep mentioning GitHub and GitLab alongside it, let's break it down.

🤔 1. Why Do We Actually Need Git?

Let's take a simple example.

Imagine you're building a login application.

You start with a basic login page. After a few days:

  • You add password validation.
  • You implement email verification.
  • You improve the authentication logic.
  • You fix a few bugs.

Everything looks good until your latest change introduces a bug.

Now you want to go back to the version that was working before.

What would you do?

Without version control, you might end up creating folders like these:

login-app/ login-app-final/ login-app-final-v2/ login-app-final-working/ login-app-final-working-latest/ 

😂 We've probably all seen something like this.

The problem is that you're manually managing different versions of your project.

It gets even worse when multiple developers are working on the same application.

You need a better way to manage changes.

That's where Git comes in.

Git is a version control system that tracks changes in your code over time.

Think of it as a history book for your codebase.

It helps you:

  • 🔍 Track what changed and when.
  • 👤 Understand who made a change.
  • ⏪ Go back to an earlier version.
  • 🌿 Work on new features without directly disturbing existing code.
  • 🤝 Combine changes made by multiple developers.

Instead of maintaining multiple copies of your project, Git maintains a history of changes in a repository.

📦 2. What Exactly Is Git?

Git is a free, open-source, distributed version control system.

That's quite a technical definition. Let's simplify it.

Version Control

It keeps track of changes made to your files over time.

For example, you can compare today's code with the code you wrote yesterday and see exactly what changed.

Distributed

Every developer can have a complete local copy of the repository, including its version history.

This means you don't need an internet connection to perform many Git operations.

Version Control System

Git provides commands and mechanisms to manage changes, create versions, compare code and work with branches.

Here's something important:

Git works directly on your local machine.

You don't need GitHub or GitLab to start using Git.

You can create a repository, track changes, create commits and manage branches without an internet connection.

💡 For example:

git init 

This initializes a new Git repository in your current directory.

That's it. You now have a Git repository locally.

No GitHub account required.

We'll explore what happens behind the scenes when we run this command in the next article.

☁️ 3. Then What Is GitHub?

Here's where things get interesting.

If Git already tracks our code and manages its history, why do we need GitHub?

Because working alone and working as a team are two different things.

Git works locally, but developers often need a shared place where they can publish their repositories and collaborate with others.

That's where GitHub comes in.

GitHub is a platform that hosts Git repositories and provides tools for collaboration.

Let's go back to our login application.

Imagine three developers working on the same project:

  • Developer A works on the login feature.
  • Developer B works on payment integration.
  • Developer C fixes existing bugs.

How do they share their changes?

They can push their local commits to a shared GitHub repository.

Other developers can review those changes, discuss them and suggest improvements before they become part of the main codebase.

GitHub also provides features like:

  • Pull Requests for reviewing and merging code.
  • Issues for tracking bugs and tasks.
  • GitHub Actions for automating workflows.
  • Project management and collaboration tools.

In simple terms:

Git manages your code history. GitHub gives your team a place to share and collaborate on that code.

🦊 4. What About GitLab?

GitLab serves a similar purpose.

It is also a platform for hosting Git repositories and collaborating with other developers.

Like GitHub, GitLab supports:

  • Repository hosting.
  • Merge Requests for code reviews.
  • Issue tracking.
  • CI/CD pipelines.
  • Project management.
  • Security and DevSecOps capabilities.

One thing worth mentioning is that GitLab offers an integrated DevSecOps platform, helping teams manage different stages of the software development lifecycle.

GitHub and GitLab have overlapping capabilities, but their interfaces, workflows and integrations are different.

Both are built around Git.

⚔️ 5. Git vs GitHub vs GitLab

Let's put everything together.

Feature Git GitHub GitLab
What is it? Version control system Git hosting and collaboration platform Git hosting and DevSecOps platform
Tracks code changes Yes Through Git repositories Through Git repositories
Works locally Yes Not its primary purpose Not its primary purpose
Repository hosting Local repositories Yes Yes
Code reviews Not built-in as a hosting workflow Pull Requests Merge Requests
CI/CD Requires additional tooling GitHub Actions GitLab CI/CD
Team collaboration Through Git workflows Yes Yes

Here's the easiest way to remember:

  • 🧠 Git: Tracks and manages changes in your code.
  • 🐙 GitHub: Helps developers share and collaborate on Git repositories.
  • 🦊 GitLab: Provides Git repository hosting, collaboration and an integrated DevSecOps platform.

🔄 6. How Do Git and GitHub Work Together?

Let's understand this with a practical example.

Imagine you're working on an e-commerce application with three other developers.

Here's a simplified workflow:

flowchart TD A["💻 Developer's Local Project"] --> B["Git tracks changes"] B --> C["📦 Create a Commit"] C --> D["☁️ Push to GitHub"] D --> E["🔍 Create Pull Request"] E --> F["👥 Code Review"] F --> G["✅ Merge into Main Branch"]

Let's understand each step.

Step 1: Get the project

Your team has a repository hosted on GitHub.

You download a local copy using Git.

Step 2: Make changes

You work on a new payment feature on your local machine.

Git tracks the changes you make.

Step 3: Save your changes

You create a commit to record your changes in Git's history.

Step 4: Share your changes

You push your commits to the shared GitHub repository.

Step 5: Get your changes reviewed

You create a Pull Request so other developers can review your implementation.

Step 6: Merge the changes

Once approved, your changes can be merged into the main branch.

That's a simplified version of how Git and GitHub work together in a development team.

The same general workflow applies when using GitLab, although GitLab calls Pull Requests Merge Requests.

💡 7. Can We Use Git Without GitHub or GitLab?

Absolutely!

This is probably one of the most important things to understand.

Git doesn't depend on GitHub or GitLab.

You can:

  • Create repositories locally.
  • Track changes.
  • Create commits.
  • Create and switch branches.
  • Merge changes.
  • View your project history.

All without creating an account on any hosting platform.

GitHub and GitLab simply make it easier to share repositories and collaborate with other developers.

Also, they're not the only options. Platforms like Bitbucket provide Git repository hosting and collaboration features too.

🎯 8. What Should You Remember?

Before moving forward, let's quickly recap.

Term Remember this
Git Tracks changes in your code
Repository A project tracked by Git
GitHub Hosts Git repositories and supports collaboration
GitLab Hosts Git repositories and provides integrated DevSecOps capabilities
Commit A recorded change in Git history
Push Sends local commits to a remote repository

One last thing: Git is not a cloud backup tool.

It's a distributed version control system. Its ability to maintain project history locally and help developers manage changes is what makes it so useful.

🚀 What's Next?

Now that we understand why Git exists, let's get our hands dirty.

In the next article, we'll create our first Git repository and understand what actually happens when we run git init.

We'll also explore:

  • What is a .git folder?
  • What happens when Git initializes a repository?
  • How does Git know which files belong to a repository?

If you're learning Git along with this series, share your questions or experiences in the comments.