DCubes
Git module

Lesson 9

Remotes

Connect a local repo to a remote name and understand fetch, pull, and push.

beginner30 minRun on your machine

What you will be able to do

  • Add a remote with git remote add
  • Explain fetch vs pull vs push
  • List remotes with -v

Why this matters for data work

The remote is the shared copy (usually GitHub). push publishes; pull updates you. Laptops are not backups by themselves.

Concepts

  • origin — conventional remote name
  • git remote add origin <url>
  • git push -u origin main — publish and set upstream
  • git fetch — download refs; git pull — fetch + merge (or rebase)

Practice on your machine

Simulate a remote with a bare repo:

cd ~/dcubes/git-lab
git init --bare origin-retail.git
cd ~/dcubes/git-lab/init-demo
git remote add origin ~/dcubes/git-lab/origin-retail.git
git remote -v
git push -u origin main
git status

What you should see

  • origin pointing at the bare path.
  • Push succeeds; branch tracks origin/main.

Common mistakes

  • Pushing without remote — add origin first.
  • Two different origin URLs across clones — remote -v to verify.

Next

GitHub basics