Course progress0%
Course content
40 min

Publish a Local Repository to GitHub

Connect two locations and send local commits

By the end of this lesson

  • Explain remote, origin and main
  • Push local commits and verify them on GitHub

A new problem needs GitHub

Yassine now has useful commits, but they exist only on his computer. He wants an online repository that his team can access.

Create an empty repository on GitHub. Do not add a README from GitHub when the local project already has its own first commit. Copy the repository URL.

Give the remote location a short name

git remote add origin REPOSITORY_URL

Read the command in plain language:

  • remote: another repository location;
  • add: remember a new location;
  • origin: the short local name for that location;
  • REPOSITORY_URL: the real GitHub address.

origin is a convention, not a special GitHub account.

Check the connection without publishing:

git remote -v

Send the branch

git push -u origin main
  • push: send commits;
  • origin: send them to this remote;
  • main: send this branch;
  • -u: remember the relationship for later pushes.

Future pushes from the same branch can usually use:

git push

Verify instead of assuming

Open the repository on GitHub and check:

  1. Are the expected files present?
  2. Does the latest commit message match the local history?
  3. Did any private file appear?

Important distinction

git commit = record locally
git push   = publish recorded commits

Pushing does not send an unsaved file or an uncommitted modification.

What to remember

A remote is another repository location. origin names the GitHub repository locally. Push sends commits, so create and review the correct local commit first.

Lesson complete?

Your progress is saved on this device.