git push and git pull use origin unless you tell them otherwise.Guide
Your commits live on your computer. Here's how to back them up and share them on GitHub.
A remote is just a copy of your repository that lives somewhere else —
usually on GitHub. By convention the main remote is nicknamed origin. When
you clone a repo, origin is set up for you automatically. When you start a repo with
git init, you connect it to GitHub yourself.
First create an empty repository on GitHub (click New on github.com). It gives you a URL. Then point your local repo at it:
Link local repo to GitHub (one time)
$ git remote add origin https://github.com/you/project.git
$ git branch -M main
$ git push -u origin main The -u in 'push -u' links your local 'main' to GitHub's 'main' so future pushes are just 'git push'.
First push asks for a login? From the terminal, GitHub needs a token or an SSH key — Connect to GitHub walks through the one-time setup.
push git push uploads your local commits to GitHub. Commit locally as often as you
like; push when you want to back up or share.
Upload your commits
$ git push A common beginner confusion: committing does NOT send anything to GitHub. Push is the step that does.
pull
When a teammate (or you, on another machine) pushes new commits, git pull
downloads them and merges them into your current branch. Pull before you start working so
you're up to date.
Get the latest changes
$ git pull fetch vs pull git fetch downloads new commits but doesn't change your files — it just
lets you see what's new. git pull is really "fetch + merge" in one step. Beginners
can stick with pull; fetch is handy when you want to look before you leap.
The daily rhythm: pull → make changes → add → commit → push. That loop covers most of what you'll ever do.
Push rejected? That "! [rejected] … (fetch first)" message just means GitHub has commits you don't — Push Rejected & Diverged Branches decodes it and shows the two-command fix.
See and manage your remotes
$ git remote -v # list remotes and their URLs
$ git push -u origin my-feature # push a NEW branch the first time
$ git push origin --delete old-branch # delete a branch on GitHub The -u (set-upstream) link is only needed the first time you push a new branch; after that, plain 'git push' works.
Working on someone else's project? Then you'll have two remotes — your fork (origin) and the original (upstream). Fork & Sync covers the whole flow.
Up next: the heart of teamwork on GitHub — proposing a change with a pull request, from branch to merge.
FAQ
git push and git pull use origin unless you tell them otherwise.git pull then git push fixes it. Push Rejected & Diverged Branches decodes the full message.git fetch downloads new commits without changing your files. git pull is fetch plus merge — it downloads and updates your current branch in one step.git remote add origin <url> and git push -u origin main.