Getting Started on GitHub, GitLab and Bitbucket
A shared office building gives every company more than a room. There is a reception desk, meeting rooms, a noticeboard and a security guard who checks who comes in. Each company still does its own work, but the building makes working together much easier.
GitHub, GitLab and Bitbucket are buildings like that for Git repositories. Each one stores your repository on its servers, the same kind of server copy you used in the previous module, and adds what a team needs around it: a web page for every file and commit, pull requests for reviewing changes, issues for tracking work, permissions for who may push, and automated builds. Git itself is the same on all three. What differs is the website and a few names.
In this lesson, you will create a repository on a platform, connect a local project to it, push, and set up your computer so that Git can sign in.
Git Is Not GitHub
This is worth repeating from "Git vs GitHub, GitLab and Bitbucket": Git is the tool on your computer, and it works without any website. GitHub, GitLab and Bitbucket are services that host Git repositories and add collaboration features. Every Git command in this course works the same with all three.
| GitHub | GitLab | Bitbucket | |
|---|---|---|---|
| Owned by | Microsoft | GitLab Inc. | Atlassian |
| Review request is called | Pull request | Merge request | Pull request |
| Built-in automation | GitHub Actions | GitLab CI/CD | Bitbucket Pipelines |
| Can run on your own servers | GitHub Enterprise Server | GitLab Self-Managed | Bitbucket Data Center |
| Often chosen by | Open-source projects, most teams | Teams that want everything in one tool, or self-hosting | Teams that use Jira and Confluence |
This course says "pull request" for all three. On GitLab, read it as "merge request".
Create a Repository on the Platform
After signing up for a free account, create a new, empty repository. The steps on each platform:
1. Click + (top right) and choose New repository.
2. Repository name: fee-tracker
3. Choose Public or Private.
4. Leave "Add a README", ".gitignore" and "license" unchecked,
because you will push an existing project.
5. Click Create repository.1. Click + (or New project) and choose Create blank project.
2. Project name: fee-tracker
3. Choose the visibility level: Private or Public.
4. Uncheck "Initialize repository with a README",
because you will push an existing project.
5. Click Create project.1. Click Create and choose Repository.
2. Choose a workspace and a project.
3. Repository name: fee-tracker
4. Set "Include a README?" to No,
because you will push an existing project.
5. Click Create repository.Each platform then shows the repository's URL, in an HTTPS and an SSH form, and the commands to push an existing project. Those are the commands from "Git Remote":
| Platform | HTTPS URL | SSH URL |
|---|---|---|
| GitHub | https://github.com/<user>/fee-tracker.git | git@github.com:<user>/fee-tracker.git |
| GitLab | https://gitlab.com/<user>/fee-tracker.git | git@gitlab.com:<user>/fee-tracker.git |
| Bitbucket | https://bitbucket.org/<workspace>/fee-tracker.git | git@bitbucket.org:<workspace>/fee-tracker.git |
Connect and Push
On her computer, Navika prepares the project with the files every good repository has, then connects it and pushes. As in the remote lessons, a bare repository in a folder stands in for the platform, because this page can't sign in to a real one. With a real platform, only the URL changes:
git init --bare --quiet github-fee-tracker.git
mkdir fee-tracker
cd fee-tracker
git init --quiet
printf "# Fee Tracker\n\nTracks school fee payments.\n" > README.md
echo "Copyright (c) 2026 Navika Anamaneni. All rights reserved." > LICENSE
echo "target/" > .gitignore
git add .
git commit --quiet -m "Start the Fee Tracker project"
git remote add origin ../github-fee-tracker.git
git push -u origin mainTo ../github-fee-tracker.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.Refresh the repository page in the browser, and the files and the commit appear. The platform shows README.md as the project's front page.
| File | Why a repository should have it |
|---|---|
README.md | The front page: what the project is, how to run it, how to contribute |
LICENSE | Who may use the code, and how. Without one, others may not legally reuse it. Platforms offer standard licenses (MIT, Apache 2.0) when you create a repository. |
.gitignore | Keeps build output and secrets out, as in "Git .gitignore" |
CONTRIBUTING.md | How to report bugs, propose changes and set up the project |
Tokens Instead of Passwords for HTTPS
The first time Git talks to a real platform over HTTPS, it asks for a username and a password. Your account password doesn't work for Git. Each platform requires a token that you create on its website and paste in place of the password:
Username: your GitHub username
Password: a personal access token
Create one: profile picture > Settings > Developer settings
> Personal access tokens. A fine-grained token limited to
the repositories you need, with "Contents: Read and write",
is enough for clone, pull and push.Username: your GitLab username
Password: a personal access token
Create one: avatar > Edit profile > Access tokens.
The scopes read_repository and write_repository
are enough for clone, pull and push.Username: your Bitbucket username (exactly as shown in your
profile settings; it is case-sensitive)
Password: an API token
Create one in your Atlassian account settings, under API tokens,
choosing Bitbucket and the scopes read:repository:bitbucket
(clone and pull) and write:repository:bitbucket (push).
API tokens replaced Bitbucket's older app passwords in 2026.Treat a token like a password: it gives access to your repositories. Give it an expiry date and only the permissions it needs. And don't type it every time: let a credential helper remember it.
Credential Helpers
A credential helper stores the token safely after the first successful sign-in, in your operating system's password store, and gives it to Git automatically from then on:
# Installed and switched on by Git for Windows (Git Credential Manager)
git config --global credential.helper manager# Uses the macOS Keychain
git config --global credential.helper osxkeychain# Git Credential Manager, if installed; otherwise keep it in memory for an hour
git config --global credential.helper manager
git config --global credential.helper "cache --timeout=3600"Git Credential Manager (GCM), included with Git for Windows and available for macOS and Linux, can also sign in to GitHub, GitLab and Bitbucket through the browser, so you may never need to copy a token at all. On Linux, pick one of the two lines above.
Never put the token inside the remote URL (https://user:token@github.com/...). It is then stored in plain text in .git/config, and appears in every git remote -v.
Syntax
| Command | It is used to |
|---|---|
git remote add origin <url> | Connect a local project to the platform repository |
git push -u origin main | Push for the first time |
git clone <url> | Copy a platform repository to your computer |
git config --global credential.helper <helper> | Let Git remember your token |
git config --global --get credential.helper | See which credential helper is set |
Common Mistakes
Typing your account password when Git asks for one. Platforms reject it for Git over HTTPS. Use a token, or SSH.
Creating the platform repository with a README, then pushing an existing project. The push is rejected because the histories are unrelated. Create it empty, or run git pull --allow-unrelated-histories origin main once to join them.
Storing a token in the remote URL. It sits in plain text in .git/config. Use a credential helper.
Pushing private keys, passwords or .env files to a public repository. Bots scan public platforms for secrets within minutes. Add them to .gitignore before the first commit.
No README. Visitors, and you in six months, can't tell what the project is or how to run it.
Under the Hood
A hosting platform stores each repository as a bare repository on its servers, like the folder used on this page, and runs Git's server programs for clone, fetch and push. Over HTTPS, your Git sends each request with the credentials the helper provided, and the platform checks them before running the request. When the push arrives, the platform updates its database, the web pages, and starts any automation, such as builds and pull request checks, configured for the repository.
Interview Corner
What is the difference between Git and GitHub?
Git is a distributed version control system that runs locally. GitHub is a hosting service for Git repositories that adds a web interface and collaboration features such as pull requests, issues, permissions and CI. GitLab and Bitbucket are similar services.
How do you push an existing local project to a new GitHub repository?
Create an empty repository on GitHub, then in the project run git remote add origin <url> and git push -u origin main.
Why doesn't your account password work for git push over HTTPS?
GitHub, GitLab and Bitbucket require a personal access token (Bitbucket: an API token) for Git over HTTPS, or SSH keys. Tokens can be limited in scope and expiry, and revoked individually, unlike a password.
What is a credential helper?
A program Git calls to store and retrieve credentials, such as Git Credential Manager or the macOS Keychain helper, configured with credential.helper. It saves the token after the first sign-in so you don't type it again.
Practice
Challenge: second project. Create a second stand-in platform repository, github-fee-receipts.git, and a new project fee-receipts next to fee-tracker, with a README.md containing # Fee Receipts. Connect it, push it with -u, and ask the "platform" which branches it has.
What does Git print? Before you open the solution, decide what the push says on the first push of main, and how many branches git ls-remote --heads lists.
Show solution
cd ..
git init --bare --quiet github-fee-receipts.git
mkdir fee-receipts
cd fee-receipts
git init --quiet
echo "# Fee Receipts" > README.md
git add README.md
git commit --quiet -m "Start the Fee Receipts project"
git remote add origin ../github-fee-receipts.git
git push -u origin mainTo ../github-fee-receipts.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.git ls-remote --heads origine18d897767902ed811ecea07bef9e76a58202380 refs/heads/mainThe first push creates main on the platform (* [new branch]) and sets the upstream. The platform now has exactly one branch, main.
Checkpoint. Create a free account on GitHub, GitLab or Bitbucket. Create an empty repository, push a small project of your own to it over HTTPS with a token, and let a credential helper remember the token. Check that a second git push doesn't ask for it again.
Key Takeaways
Quick reference
| Command | It is used to |
|---|---|
git remote add origin <url> | Connect to the platform repository |
git push -u origin main | First push |
git clone <url> | Copy a platform repository |
git config --global credential.helper manager | Use Git Credential Manager |
git config --global credential.helper osxkeychain | Use the macOS Keychain |
git remote set-url origin <url> | Switch between HTTPS and SSH URLs |
Was this tutorial helpful?