Remotes and GitHub

What a remote is

Understand a remote as a named connection to another Git repository.

8 minute lesson

~~~

A remote is a named set of URLs for another Git repository.

Inspect the configured remotes with:

git remote -v

You might see a name such as origin beside fetch and push URLs. origin is a convention created by git clone; it is not a special server. A project can have no remotes, one remote, or several.

A remote name is configuration. Remote-tracking references are local names such as origin/main that record the remote branch state from your last network operation.

This distinction matters. main is a local branch that you can commit on. origin/main is Git’s local record of the remote branch. It changes when you fetch or successfully push, not when someone changes the server while you are offline.

Local commits stay local until you push them. Remote commits do not appear locally until you fetch them.

Use these read-only commands to inspect both:

git remote get-url origin
git branch --all
git log --oneline --decorate --graph --all

Exercise: point to main, origin/main, and origin in the output. Explain which one is a branch, which one is a remote-tracking reference, and which one is configuration.

Lesson completed

Take this course offline

Get every free book, course edition, and software download.

Get the download library →