How do you link a local repository to a remote one?
After initializing a Git repo locally (git init), you can connect it to a remote repository
(like one on GitHub) using:
git remote add origin
Then push your code:
git push -u origin main
Explanation:
- origin is just a nickname for the remote URL.
- The -u flag links your local branch with the remote one so future pushes are easier
(git push alone works after that).
Follow:
Real-world example:
You create a local portfolio website and later decide to host it on GitHub. You connect your
local repo to the remote one using git remote add origin so both stay in sync.