🔥 0
0
Lesson 9 of 10 25 min +150 XP

Working with Remotes

So far, everything has been local on your computer. Remotes let you sync your repository with servers like GitHub, GitLab, or Bitbucket.

Local vs Remote

LocalRemote
On your computerOn a server (GitHub, etc.)
Only you can accessOthers can access
Work offlineNeeds internet
Your working copyBackup + collaboration

The Origin Remote

When you clone a repository or add a remote, it's typically called origin:

# Add a remote
git remote add origin https://github.com/you/repo.git

# View your remotes
git remote -v

Pushing Changes

To upload your commits to the remote:

git push origin main

This sends your local main branch commits to the origin remote.

Pulling Changes

To download changes from the remote:

git pull origin main

This fetches remote commits and merges them into your local branch.

Cloning a Repository

To create a local copy of a remote repository:

git clone https://github.com/someone/repo.git

This:

  • Creates a new folder with the repo name
  • Downloads all commits and branches
  • Sets up origin automatically
  • Checks out the default branch

The Push/Pull Workflow

Your Computer                    GitHub
┌─────────────┐                 ┌─────────────┐
│   Local     │ ───push───►    │   Remote    │
│   Repo      │ ◄───pull────   │   Repo      │
└─────────────┘                 └─────────────┘
  • Make changes locally
  • Commit them
  • Push to share with others
  • Pull to get others' changes

Try It Out!

Use the remote simulator to practice pushing and pulling.

Visual Mode: Click "Push" and "Pull" buttons to sync Command Mode: Use git push and git pull commands

Watch commits flow between your local repo and the remote!

Merging Branches