Git vs GitHub, GitLab and Bitbucket
"I put it on Git." "Is it on GitHub?" "Send me the Git link." New developers hear these sentences on their first day and often conclude that Git and GitHub are two names for one thing. They are not, and mixing them up causes real confusion later.
Here is a comparison that helps. A camera takes photos and keeps them in an album at your home. A photo-sharing website is where you upload that album so your family can see it and add their own photos. The camera works perfectly well without the website. The website would have nothing to show without cameras.
Git is the camera. GitHub, GitLab and Bitbucket are photo-sharing websites. This lesson explains what each one does and how the three websites compare.
Git Is the Tool
Git is a version control program that runs on your own computer. It records commits, keeps the history, creates branches and combines them. It needs no account and no internet connection, and it is free and open source. No company owns it.
Everything you learned in the lesson "What Is Git" was Git alone. Navika created a repository and made commits, and no website was involved.
GitHub, GitLab and Bitbucket Are Hosting Services
A hosting service is a website that stores a copy of your Git repository on its servers. That online copy is what Git calls a remote. A hosting service is used to:
- share a repository, so that everyone on the team pushes to and pulls from one agreed place;
- back up your work somewhere other than your laptop;
- review changes before they are accepted, using a pull request (a page where teammates read and discuss a proposed change);
- track bugs and tasks as issues;
- run automatic checks, such as building the project and running its tests after every push;
- control access, so the right people can read or change each repository.
Pull requests, issues and automatic checks are features of the websites. They are not part of Git, which is why they look a little different on each service.
Git vs GitHub at a Glance
| Git | GitHub (and GitLab, Bitbucket) | |
|---|---|---|
| What it is | A version control program | A website that hosts Git repositories |
| Where it runs | On your computer | On the company's servers, in your browser |
| First released | 2005 | GitHub in 2008 |
| Owned by | Nobody; it is an open-source project | A company |
| Needs internet | No | Yes |
| Needs an account | No | Yes |
| Main job | Record and manage history | Share repositories and help teams work together |
| You use it through | The git command, or an editor that runs it | A web page, plus git push and git pull |
Proof That Git Works Without a Website
Navika creates a new repository and makes one commit. Then she asks Git to list its remotes with git remote -v:
mkdir fee-tracker
cd fee-tracker
git init --quiet
echo "Fee Tracker" > README.md
git add README.md
git commit --quiet -m "Add project README"
git remote -v
git log --onelinedd34d8a (HEAD -> main) Add project READMEHow it works
--quietasksgit initandgit committo do their work without printing a message, so the output stays short.git remote -vprints nothing, because this repository has no remote. It isn't connected to any website.git log --onelinestill shows the commit. The history is complete and it lives on Navika's computer.
A repository is a full repository from its first commit. A hosting service is something you add when you want to share.
Comparing the Three Hosting Services
GitHub, GitLab and Bitbucket all host Git repositories, and the Git commands you type are the same for all three. They differ in who runs them and in the features built around Git.
| GitHub | GitLab | Bitbucket | |
|---|---|---|---|
| Launched | 2008 | 2011 | 2008 |
| Owned by | Microsoft (since 2018) | GitLab Inc. | Atlassian (since 2010) |
| Known for | The largest home of open-source code | One product for the whole process, from planning to release | Working closely with Jira and other Atlassian tools |
| Name for a proposed change | Pull request | Merge request | Pull request |
| Built-in automation | GitHub Actions | GitLab CI/CD | Bitbucket Pipelines |
| Run it on your own servers | GitHub Enterprise Server | GitLab Self-Managed (has a free, open-source edition) | Bitbucket Data Center |
| Free plan | Yes | Yes | Yes |
A pull request on GitHub and Bitbucket and a merge request on GitLab are the same idea with two names: "please review my changes and add them to the main branch".
This course uses GitHub for its main examples. Where the steps on GitLab or Bitbucket are different, the lesson shows them side by side in tabs.
Do You Need a Hosting Service?
Not to learn Git. Every lesson until "Git Remote" works with a repository on your own computer.
You will want one when:
- you work with other people, because everyone needs a shared place to push to and pull from;
- you want a backup that survives a lost or broken laptop;
- you want to show your work to others, for example in a job application;
- you want to contribute to an open-source project.
Common Mistakes
Saying "I installed GitHub". You install Git. GitHub is a website you sign in to. There is an app named GitHub Desktop, but it is a window with buttons that runs Git for you.
Thinking a commit is on GitHub. git commit saves to the repository on your computer. Your work reaches GitHub only when you run git push. If your laptop is lost before you push, the website has nothing.
Thinking Git needs GitHub. Git was released in 2005 and GitHub in 2008. Git works alone, with any hosting service, or with a plain server that your company runs.
Believing the website is the "real" copy. Your local repository is a complete repository with the full history. The copy on the hosting service is special only because the team agreed to share through it.
Expecting pull requests in Git. A pull request is a feature of the hosting website. Git has no git pull-request command for opening one, and the name is different on GitLab.
Interview Corner
What is the difference between Git and GitHub?
Git is a distributed version control system: a program that runs on your computer and records the history of a project. GitHub is a web-based hosting service for Git repositories. It stores a remote copy of the repository and adds features for teams, such as pull requests, code review, issues and automation. Git works without GitHub, but GitHub is built on Git.
Can you use Git without GitHub?
Yes. Git is complete without any hosting service. You can create repositories, commit, branch and merge entirely on your own computer. To share work, a team can use GitHub, GitLab, Bitbucket, or a Git server it runs itself.
What is the difference between a pull request and a merge request?
They are the same thing with different names. GitHub and Bitbucket call it a pull request, and GitLab calls it a merge request. In both cases, a developer pushes a branch and asks the team to review it and merge it into another branch, usually main.
Name some alternatives to GitHub.
GitLab and Bitbucket are the best-known. Others include Azure DevOps Repos and self-hosted options such as Gitea and Forgejo. All of them host Git repositories, so the Git commands stay the same.
Practice
Sort these into "Git" or "hosting service". Decide for each one, then check your answers.
- Saving a commit
- Opening a pull request
- Creating a branch
- Reporting a bug as an issue
- Looking at the history while you are offline
- Giving a teammate permission to read a private repository
Show the answers
Git: 1 (saving a commit), 3 (creating a branch), 5 (looking at the history offline). Hosting service: 2 (opening a pull request), 4 (reporting an issue), 6 (giving a teammate access).
Challenge: connect a repository to a remote. Continue the session from this lesson. The command git remote add origin <address> gives your repository the address of a remote and names it origin. Add the address https://github.com/your-username/fee-tracker.git, then list the remotes again.
What does Git print? Before you open the solution, decide what git remote -v shows this time. Has anything been uploaded?
Show solution
git remote add origin https://github.com/your-username/fee-tracker.git
git remote -vorigin https://github.com/your-username/fee-tracker.git (fetch)
origin https://github.com/your-username/fee-tracker.git (push)git remote -v now lists origin twice: once as the address to download from (fetch) and once as the address to upload to (push). Nothing has been uploaded. git remote add only saves an address in your local repository, and it doesn't contact the website at all. The commit goes to GitHub when you push, which you will do in the lessons on remote repositories.
Key Takeaways
Quick reference
| Command | It is used to |
|---|---|
git remote -v | List the remotes of a repository and their addresses |
git remote add origin <address> | Save the address of a remote under the name origin |
git init --quiet | Create a repository without printing a message |
Was this tutorial helpful?