ILILCode
HomeGitRecovery & remotes

Remotes: sharing a repository

A remote is a named URL. Add one, push your branch, and pull other people's commits.

Lesson 9 of 9 in Git9 min1 exercise

A remote is a name for a repository hosted somewhere else — another folder, a company server, or a hosting service. origin is the conventional name for the main one.

Connect, push, pull
git remote add origin git@example.com:you/notes.git

git push -u origin main     # first push, remember the pairing
git push                    # afterwards

git pull                    # fetch + merge the remote branch
git clone git@example.com:you/notes.git  # copy a repository

-u sets the upstream: it tells the local branch which remote branch it belongs to. After that, plain git push and git pull know where to go.

Exercises

Checked in your browser · hints and solutions included

01

Exercise

Publish main

Push your local main branch to the remote origin and set it as the upstream branch, in one command.

terminal