Terms
- Remote
- A remote repo that is associated with a local repo.
- Origin
- A shorthand name for the default remote repository URL.
Assumptions
- Git installed and configured
- GitHub Account created
- Existing local repo exists (with no linked remotes)
Link and push initial commit to empty local repo
- Navigate to the root directory of the repo you’d like to push.
- Ensure you have a clean working tree with
git status
. -
Ensure there aren’t already remotes attached to your local repo:
$git remote -v
Should return nothing.
- Create an empty remote repo on GitHub.
- Name your repo.
- Add a description (optional)
- Choose “Public” if you’d like to publish to GH Pages.
- Do NOT check any boxes under “Initialize this repository with…” and submit.
-
Step 4 will lead you to a page of commands to enter, depending on your situation. Copy the code under the heading …or push an existing repository from the command line, paste them into your terminal and run them:
$ git remote add origin <remote-repo-url> $ git branch -M main $ git push -u origin main
- Refresh the GitHub page and you should see your code listed instead of the example commands.