Lesson 5 of 8
Remotes: push, pull & GitHub
Learn to push your work to a remote copy on a server such as and pull other people's changes. Remotes are how teams share code and how you back up your work.
# Connect your repo to an empty GitHub repository:
git remote add origin https://github.com/you/my-project.git
# Upload your commits:
git push -u origin main
# (-u links the branches; afterwards plain 'git push' works)
# Download someone else's repository:
git clone https://github.com/them/cool-project.git
# Get new commits from the remote:
git pull'origin' is just the conventional nickname for the remote you cloned from or first added. push sends your new commits up; pull brings new commits down and merges them into your branch. If you and a teammate both pushed, you must pull (and maybe resolve a conflict) before you can push.
The collaboration workflow on top of this is the pull (PR): push your branch to the remote, open a PR proposing it be merged into main, teammates review and , then it's merged on the server. PRs are a GitHub/GitLab feature rather than a git one — but they're how virtually all team development works.
# Typical team flow:
git switch -c fix-header
# ...edit, add, commit...
git push -u origin fix-header
# Then open a Pull Request on GitHub from 'fix-header' into 'main'.
# After it's merged on GitHub:
git switch main
git pull
git branch -d fix-headerTip: use the ← and → keys to move between lessons.