GitHub and Remote Repositories

intermediate20 min

Remotes

A remote is another copy of the repo, usually on GitHub. Push sends your commits up; pull brings others’ commits down and merges them into your current branch.

Git runs on your machine. GitHub stores the shared remote and adds issues, pull requests, and permissions.

Connect a local repo

  • Create a repository on GitHub (empty or with a README)
  • Add the remote: git remote add origin <url>
  • Check: git remote -v
  • First push: git push -u origin main (sets upstream)

Sync commands

git push origin branch-name     # Push changes
git pull origin branch-name      # Pull changes
git fetch                        # Download without merging
git clone repository-url         # Clone existing repo
git push -u origin main         # Set upstream branch

Authentication

SSH keys are common for push/pull without typing a password each time. HTTPS with a personal access token also works. Enable two-factor authentication on your GitHub account. Team leads set who can read or write the org repos.

Further Reading Resources