Skip to main content

Remote Repositories

Level: Beginner

ℹ️ What You'll Learn
  • Add remote repository
  • Push to remote
  • Pull from remote
  • Sync team changes
  • Multiple remotes

Add Remote

git remote add origin https://github.com/TeamSahasra/SMS.git
git remote -v
# origin https://github.com/TeamSahasra/SMS.git (fetch)
# origin https://github.com/TeamSahasra/SMS.git (push)

Origin = remote server (usually GitHub).

Push to Remote

First time (new branch):

git push -u origin feature/exam-module
# -u sets upstream tracking

Subsequent pushes:

git push
# Assumes origin feature/exam-module

Push all branches:

git push --all

Pull from Remote

Get latest from server:

git pull origin main
# Fetch + merge in one command

# Equivalent to:
git fetch origin main
git merge origin/main

Pull current branch:

git pull

Sync Team Changes

Team updated SMS project:

# Get updates
git fetch
# or
git pull

# Your local code + team changes merged

Multiple Remotes

Two GitHub accounts or mirrors:

git remote add origin https://github.com/TeamSahasra/SMS.git
git remote add backup https://github.com/Backup/SMS.git

git push origin main
git push backup main

SMS Workflow

# Clone repository (first time)
git clone https://github.com/TeamSahasra/SMS.git
cd SMS

# Create feature branch
git checkout -b feature/fees

# Work, commit
git add .
git commit -m "Add fee payment system"

# Push to GitHub
git push -u origin feature/fees

# Create Pull Request on GitHub
# Team reviews, approves

# Merge on GitHub
# Pull updated main
git checkout main
git pull origin main

# Delete local feature branch
git branch -d feature/fees

Key Takeaways

  • Remote = server repository
  • Push = upload commits
  • Pull = download and merge
  • Sync = keep local updated
💡 Remote Tip

Pull before pushing. Avoid conflicts.

🤖Use AI to Learn Faster

Use ChatGPT, Claude, or Copilot to go deeper on Git Remote. Try these prompts:

  • "How do I push to GitHub?"
  • "What's the difference between fetch and pull?"
  • "How do I sync with team changes?"
  • "Quiz me on remote repos"

💡 Tip: After reading this article, paste your own code into AI and ask "What could go wrong here and why?" — fastest way to find edge cases and deepen understanding.

nexcoding.in