Remotes and GitHub — Push, Fetch, Pull
Your repository lives on your laptop. The deploy server, your teammates and the CI system all need the same history. A hosted remote, most often on GitHub, is the shared meeting point everyone syncs with.
The rule
Your repo is complete locally; push and pull only sync it with a remote.
Every Git clone holds the full history. A remote is simply another copy of the repository at a URL, conventionally named origin. GitHub hosts such copies and adds a web interface, access control, issues, pull requests and automation around them.
git clone git@github.com:acme/notes-api.git # copy the repo and set origin
git remote -v # list remotes and their URLs
git push -u origin feature/search # publish a branch, remember the link
git fetch origin # download new commits, change nothing locally
git pull # fetch, then merge into your branch- push sends your commits to the remote branch.
- fetch downloads the remote's new commits into tracking branches such as
origin/main, without touching your work. - pull is fetch plus merge (or rebase, if you configure it).
For authentication GitHub accepts SSH keys (URLs like git@github.com:...) or HTTPS with a personal access token. Account passwords do not work for Git operations.
If the remote has commits you do not have, Git rejects your push as "non-fast-forward". It will not overwrite others' work. You pull, resolve any conflicts, and push again.