Remotes and GitHub

What a remote is

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

A remote is a named set of URLs for another Git repository. It is configuration on your machine, not a copy of the project living somewhere else by itself.

After you clone notes-project from GitHub, inspect the configured remotes:

cd notes-project
git remote -v

You might see:

origin  [email protected]:flaviocopes/notes-project.git (fetch)
origin  [email protected]:flaviocopes/notes-project.git (push)

origin is a convention created by git clone. It is not a special GitHub feature. A project can have no remotes, one remote, or several.

Remote-tracking references are local names such as origin/main. They record the remote branch state from your last network operation.

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

Make a local commit on main without pushing:

git commit -m "Update notes" --allow-empty
git log --oneline --decorate -2

You might see:

def5678 (HEAD -> main) Update notes
abc1234 (origin/main) Previous commit

Your local main moved. origin/main stayed put until you push or fetch.

After git fetch origin, origin/main may jump ahead while your files stay the same until you merge or pull. That gap is normal. It is why git status compares main to origin/main instead of calling them the same thing.

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

In the output, point to main, origin/main, and origin. main is a branch. origin/main is a remote-tracking reference. origin is configuration.

A common mistake: assuming git pull updated your files when you only ran git fetch. Fetch moves origin/main. Your working tree stays on main until you merge or pull.

Try this on a cloned notes-project: run the commands above and explain which label is which before you push or pull anything.

Lesson completed