Working with remotes
clone, push, pull, fetch — sync your repository with a server like GitHub.
- Explain what a remote is and how local and remote history relate
- Clone, push, and pull a repository
- Distinguish fetch from pull
So far everything has lived on your machine. A remote is a copy of your repository hosted elsewhere — usually a service like GitHub — that you sync with. Remotes give you a backup, a place to collaborate, and the thing CI/CD deploys from. Crucially, git is distributed: your local repo is complete on its own, and you sync with the remote deliberately.
Getting a repository: clone
To start from an existing remote repo, clone it — this downloads the full history and sets up the link automatically:
git clone https://github.com/user/project.git
cd projectThe remote is now known to your repo as origin (the default name).
Sending and receiving changes
Two everyday commands keep local and remote in sync:
git push # send your local commits up to the remote
git pull # bring the remote's new commits down and merge them inThe first time you push a new branch, set its upstream so future pushes are just
git push:
git push -u origin add-loginfetch vs pull
These are often confused:
git fetchdownloads the remote's new commits but does not change your working files. It just updates your knowledge of the remote.git pullisfetchplusmerge— it downloads and integrates the changes into your current branch.
fetch is the cautious move: look at what changed (git log origin/main) before
deciding to merge. pull is the convenient one when you're ready to take the
changes.
Do it yourself: create an empty repo on GitHub, then from your local
project run the git remote add origin … and git push -u origin main lines
it shows you. Refresh the page — your commits are there. You've done the full
local-to-remote round trip by hand.
When the agent's away
Cloning, branching, committing, and pushing are the entire day-to-day loop of shipping code. With just these commands you can pull down a project, make a change on a branch, and push it for review — no assistant required. That independence is the whole point of this module.
Where to go next
You've completed the beginner Git module — you can manage the full local-and- remote workflow yourself. The intermediate Git in practice module goes deeper: merging vs rebasing, resolving conflicts by hand, and undoing anything.