← Back to Git Course | Chapter 4: Remote Repositories | Lesson 1 of 11

Git Remote Introduction

What is a Git Remote?

A remote is simply a copy of your repository hosted somewhere else -- typically on a service like GitHub -- that acts as the shared meeting point where team members exchange commits rather than emailing files back and forth.

Example: What is a Git Remote?

bash
git remote -v

Cloning a Repository

Cloning a repository doesn't just copy its files -- it also automatically configures a remote connection (named origin by default) back to the source, so your local copy already knows where to fetch updates from.

Example: Cloning a Repository

bash
git clone https://github.com/user/repo.git
git remote -v

Pushing to Remotes

Pushing uploads your local commits to a remote, making your work visible to everyone else with access to it -- until you push, your commits exist only on your own machine, invisible to collaborators.

Example: Pushing to Remotes

bash
git push origin main

Pulling from Remotes

Pulling downloads a remote's new commits and merges them into your currently checked-out local branch in one step, which is how you stay in sync with changes teammates have already pushed.

Example: Pulling from Remotes

bash
git pull origin main

Fetch vs Pull

Fetch and pull are related but distinct: fetch only downloads new commits and lets you inspect them before deciding what to do, while pull immediately merges those downloaded commits into your current branch as well.

Example: Fetch vs Pull

bash
git fetch origin
git pull origin main

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.