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:
- Are the expected files present?
- Does the latest commit message match the local history?
- 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.