Remote Repositories in Git

From the Git cheat sheet · Working with Remotes · verified Jul 2026

Remote Repositories

Connect and sync with remote repositories

bash
# Show remotes
git remote
git remote -v

# Add remote
git remote add origin <url>

# Change remote URL
git remote set-url origin <new-url>

# Remove remote
git remote remove origin

# Rename remote
git remote rename origin upstream
💡 Origin is the default remote name
⚠️ Force push can overwrite others' work
✅ Use --force-with-lease for safer force pushing
⚡ Fetch updates remote tracking branches
Back to the full Git cheat sheet