Script Valley
Git and GitHub Complete Course: From Beginner to Advanced
Working with GitHub: Remotes, Push, Pull, and CollaborationLesson 3.1

Connecting Local Repositories to GitHub

git remote, git push, git clone, origin, remote URL, SSH vs HTTPS, GitHub repository creation

Connecting Local Repositories to GitHub

GitHub is a cloud hosting platform for Git repositories. Once your local repository is connected to GitHub, you can share your code, collaborate with others, and back up your history remotely.

DiagramLocal to GitHub Remote Connection

IMAGE PROMPT (replace this block with your generated image):

Flat connection diagram on white background. Title: Connecting a Local Repo to GitHub. Left side: laptop box labeled Local Repository with a folder icon and stacked commit circles C1 C2 C3. Right side: GitHub logo box labeled GitHub Remote (origin) with cloud icon and same commit circles. Center: two parallel horizontal arrows. Top arrow (blue, #3A5EFF): labeled git push -u origin main pointing right. Bottom arrow (green): labeled git pull / git fetch pointing left. Below the diagram: two authentication method cards side by side. Card 1: HTTPS — lock icon, label: username + personal access token, badge: simpler setup. Card 2: SSH — key icon, label: public/private key pair, badge: no credentials per push (recommended). Three-step setup flow at bottom: 1. git remote add origin URL → 2. git push -u origin main → 3. git push (future). Monospace for commands, white background, brand color #3A5EFF for push arrow.

Creating a GitHub Repository

Log in to GitHub and click the plus icon to create a new repository. Give it a name, choose public or private visibility, and optionally add a README. Do not initialize with a README if you are connecting an existing local repository.

Adding a Remote

A remote is a reference to a repository hosted on a server. Add GitHub as your remote origin:

git remote add origin https://github.com/username/repo-name.git

The name origin is a convention — it means the main remote server. You can have multiple remotes with different names.

Pushing for the First Time

git push -u origin main

The -u flag sets the upstream tracking relationship. After this, you can simply run git push and Git knows where to push.

SSH vs HTTPS Authentication

HTTPS requires a username and personal access token. SSH uses a key pair — a private key on your machine and a public key registered on GitHub. SSH is more convenient for daily use because it does not require entering credentials. Set up SSH with ssh-keygen -t ed25519 -C "email@example.com" and add the public key to your GitHub account under Settings > SSH Keys.

Up next

Fetching, Pulling, and Pushing Changes

Sign in to track progress