Bringing your local repository to GitHub: understanding the concept of remotes and the origin alias, creating a new repository on GitHub, connecting it with git remote add, making your first push with -u origin main, and cloning repositories.

For seven episodes, all your work has been local: commits, diffs, branches, and merges are stored neatly in the .git folder on your own machine. That protects you from mistakes, but not yet from far more common disasters: a broken laptop, a dead hard drive, or simply the need to share code with your teammates.
In this episode you learn to bring your repository to GitHub — the most popular remote repository platform in the world. This is where Git changes from a personal tool into the foundation of collaboration: a single source of truth that many people can access from anywhere.
A remote repository is a copy of your repository located outside your machine — on GitHub, GitLab, or Bitbucket servers. Technically, a remote is just a URL where Git can send and pull commits, not a separate database with special rules.
Because a project can connect to many remotes, Git gives each one an alias name. The industry standard convention: the main remote is named origin. It is not a special keyword — just an alias name honored all over the world, so when you read origin/main you immediately understand its meaning: the main branch on the main remote.
Before connecting, prepare the container on GitHub first. Through the UI, the steps are:
1. Klik ikon + di pojok kanan atas, pilih New repository.
2. Isi Repository name, misalnya kafe-pos.
3. Pilih visibility: Public atau Private.
4. Biarkan kotak README dan .gitignore kosong untuk repo lokal yang sudah ada.
5. Klik Create repository.Note
Choose Public if you want the code visible to everyone (open source), Private if it should stay closed. Do not worry — visibility can be changed at any time from the repository Settings.
Once created, GitHub displays an empty page with instructions. We will follow the "push an existing repository from the command line" path.
From the terminal, link your local repository to the newly created remote. Git uses the URL shown on the GitHub page, in two forms: HTTPS or SSH.
git remote add origin https://github.com/arman-dwi/kafe-pos.gitReplace arman-dwi and kafe-pos with your account and repository name. This command only records the address; no data is sent.
Confirm the connection with git remote -v (v stands for verbose):
git remote -vorigin https://github.com/arman-dwi/kafe-pos.git (fetch)
origin https://github.com/arman-dwi/kafe-pos.git (push)Two lines appear: one for pulling (fetch), one for pushing (push). They are almost always identical.
Now send the entire local commit history:
git push -u origin mainThe -u flag (short for --set-upstream) does two things: sends the commits, and records the tracking relationship between the local main branch and origin/main. After that, Git knows which remote to sync with, so subsequent commands only need git push or git pull without mentioning origin main again.
Enumerating objects: 32, done.
Writing objects: 100% (32/32), 6.40 KiB | 0 bytes/s, done.
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.Tip
This step is only done once per branch. Get into the habit of always writing git push -u origin <branch-name> the first time you push a new branch — it will save you a lot of confusion in episode 9.
The opposite of push: clone copies an entire repository from the remote to your local machine. This is the standard way to join an existing project.
git clone https://github.com/arman-dwi/kafe-pos.gitWhen it finishes, three things are already set up for you:
origin remote already registered.main branch checked out and tracking origin/main.Running git remote -v inside the cloned folder will immediately show origin. No need for git remote add again.
Warning
Be careful with empty repositories: cloning a truly empty repository (with no commits yet) produces a folder with no active branch. This is a normal condition, not an error — just run git switch -c main and start committing.
Key points of this episode:
origin.git remote add origin <URL>.git remote -v to check the fetch and push addresses.git push -u origin main for the first push; -u records the upstream tracking.git clone <URL> copies a complete repository along with the origin remote.Now your repository lives in two places: local and GitHub. In episode 9 we enter real team mode — learning to tell git fetch and git pull apart, keeping history tidy with git pull --rebase, and managing remote branches. See you there!