Lessons in this course (10)

3. Remotes — fetch, pull, push

Basic★ Must knowLesson 3 of 10
bash
git remote -v                          # list remotes
git fetch origin                       # download new commits, do NOT change your branch
git pull                               # fetch + merge (or rebase if pull.rebase=true)
git pull --rebase                      # fetch + replay your local commits on top
git push -u origin feature/login       # first push, set upstream
git push                               # later pushes
git push --force-with-lease            # safe force-push after rebase (fails if someone else pushed)
CommandChanges your working branch?
git fetchNo — updates origin/* remote-tracking branches only
git pullYes — fetch then merge/rebase into your branch

Interview tip: "fetch is safe, pull integrates" — and never use plain --force on a shared branch; use --force-with-lease.