Daily Workflow

GitHub: Push, Pull & Clone

~25 min

GitHub: Push, Pull & Clone

GitHub is where your code lives in the cloud. It's your backup, your portfolio, and how you collaborate with others.

💾

Backup

Your code is safe even if your computer dies

👥

Collaboration

Work with others from anywhere

🌍

Portfolio

Show your work to the world

Local vs Remote

💻

Local Repository

On your computer

  • •Where you write code
  • •Where you commit changes
  • •Works offline
☁️

Remote Repository

On GitHub's servers

  • •Backup of your code
  • •Shared with others
  • •Accessible anywhere

Local push -> <- pull Remote

Step by Step

Create a Remote Repository

Go to github.com and click the + icon in the top right, then select New repository.

On GitHub: Click + -> New repository

  • •Give it a name (e.g., my-first-repo)
  • •Choose public or private
  • •Do not initialize with README if you have existing code
  • •Click "Create repository"

Quick Reference

CommandWhat it does
git remote -vList all remotes
git remote add origin URLAdd a new remote called "origin"
git push -u origin mainPush and set up tracking
git pushPush commits to remote
git pullFetch and merge remote changes
git fetchDownload remote changes (don't merge)
git clone URLCopy a remote repo to your computer

HTTPS vs SSH

HTTPS

https://github.com/user/repo.git

  • •Works everywhere
  • •Easy to set up
  • •May ask for credentials

SSH

git@github.com:user/repo.git

  • •No password prompts
  • •More secure
  • •Requires SSH key setup

Start with HTTPS. Switch to SSH later when you are comfortable.

Best Practices

  • • Pull before you push - always get the latest changes first.
  • • Commit often, push regularly - small, frequent updates are safer.
  • • Write good commit messages - your teammates will thank you.
  • • Do not commit sensitive data - passwords, API keys, etc. should stay out of Git.

You now know the basics of connecting local and remote repositories!