Learning Objectives
By the end of this lesson you will be able to:
- Explain what a remote is and what the name
originmeans - Create an empty repository on GitHub or GitLab and connect your local one to it
- Inspect, correct, and remove a remote
- Choose between HTTPS and SSH and set up authentication that works
What a Remote Is
Everything you've built so far lives in one place: the .git folder on your laptop. A remote is another copy of that same repository, living somewhere else — usually on a server like GitHub, GitLab, or Bitbucket.
Two important things about remotes:
A remote is a full repository, not a backup file. It has the complete history, every commit, everything. That's why Git is called distributed: there's no single master copy, just many equal copies that sync with each other.
Nothing syncs automatically. Git never contacts a remote unless you explicitly tell it to, with push, pull, fetch, or clone. Your local commits stay local until you say otherwise — which is exactly why an uncommitted, unpushed repository is not a backup of anything.
origin Is Just a Nickname
By near-universal convention the first remote you add is named origin. There's nothing special about the word — it's a short alias so you don't type https://github.com/olena/qa-notes.git twenty times a day.
A repository can have several remotes with different names (origin, upstream, fork), but for everything in this trail, one remote named origin is all you need.
Step 1: Create the Empty Remote Repository
On GitHub: New repository → give it a name (qa-notes) → choose Private if it holds anything internal → and do not tick "Add a README", "Add .gitignore", or "Choose a license".
That last part matters. Those options create a commit on the server, and connecting a local repository that already has its own commits to a server repository that also has commits produces exactly the "unrelated histories" error that ruins a beginner's afternoon. Start the remote empty.
GitLab is the same flow: New project → Create blank project → untick "Initialize repository with a README".
Step 2: Connect Them
Copy the URL the platform shows you and run:
git remote add origin https://github.com/olena/qa-notes.git
Nothing visible happens, and nothing is transferred. This command only writes an address into your repository's config. Verify it:
git remote -v
origin https://github.com/olena/qa-notes.git (fetch)
origin https://github.com/olena/qa-notes.git (push)
Two lines — one for downloading, one for uploading. They're normally identical.
Fixing a Mistake
Wrong URL? You don't need to start over:
git remote set-url origin https://github.com/olena/qa-notes-v2.git
Want it gone entirely?
git remote remove origin
Neither command touches a single commit. Remotes are configuration, not history.
HTTPS or SSH?
The platform offers two URL formats, and this is where most first-time setups stall.
HTTPS — https://github.com/olena/qa-notes.git Works everywhere, including behind restrictive corporate firewalls. But GitHub has not accepted your account password for Git operations since 2021: you must generate a Personal Access Token in your account settings and use that as the password when prompted. Your system's credential helper will remember it after the first time.
SSH — git@github.com:olena/qa-notes.git You generate a key pair once (ssh-keygen -t ed25519 -C "olena@example.com"), paste the public half into your account settings, and never type a credential again. More setup on day one, less friction every day after.
Start with HTTPS if you want to be pushing in the next five minutes. Move to SSH the first weekend you have twenty spare minutes.
Pro Tip: If a
git pushever fails with "Authentication failed" or "Support for password authentication was removed", you're almost certainly typing your account password where a Personal Access Token belongs. It's the single most common first-push failure, and it has nothing to do with your Git knowledge.
Key Takeaways
- A remote is a complete copy of your repository hosted elsewhere, not a backup file
originis the conventional nickname for your main remote — an alias for a URL, nothing more- Create the remote repository empty, with no README, to avoid the "unrelated histories" error
git remote add origin <url>only writes config;git remote -vconfirms it,set-urlcorrects it- HTTPS needs a Personal Access Token instead of a password; SSH needs a key pair set up once