Git Advanced: Working with Remotes

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


A Git remote is a reference to a repository hosted elsewhere, typically on a service like GitHub, GitLab, or BitBucket.

Understanding how to manage remotes is essential when you need to change where your repository is hosted or work with multiple remote repositories.

Viewing Remotes

To see which remotes are configured for your repository:

git remote -v

This lists all remotes along with their URLs for fetching and pushing.

Adding a Remote

To add a new remote to your repository:

git remote add origin git@github.com:username/repo.git

The origin is the conventional name for your primary remote, but you can use any name. Change username/repo to match your actual repository URL.

You might need to add a remote when:

  • You initialized a local repository and want to connect it to GitHub
  • You want to add a second remote for deploying to a different service
  • You removed the old remote and need to add a new one

Removing a Remote

To remove a remote from your repository:

git remote rm origin

This removes the reference to the remote repository. It doesn’t delete the remote repository itself, just your local reference to it.

Common scenarios where you’d remove a remote:

  • Moving your project to a different hosting service
  • Creating an archive copy of a website with its own repository
  • Cleaning up after a project restructure

After removing a remote, git remote -v won’t return anything for that remote name.

Renaming a Remote

To rename an existing remote:

git remote rename old-name new-name

Adding a New Remote After Removal

A common workflow is removing the old remote and adding a new one:

# Remove the old remote
git remote rm origin

# Add the new remote
git remote add origin git@github.com:username/new-repo.git

# Push to the new remote
git push -u origin main

If you use GitHub Desktop, you can also drag your folder into the app after removing the remote, and it will help you create a new GitHub repository.

Lessons in this unit:

0: Introduction
1: ▶︎ Working with Remotes
2: Squashing Commits
3: Rebase vs Merge
4: Git Bisect for Debugging
5: Git Worktrees
6: Git Submodules
7: Understanding Detached HEAD
8: Managing Secrets in Git
9: Git Workflows and Best Practices
10: How to push to 2 repositories at the same time and keep them in sync
11: How to update a Git branch from another branch
12: Git, detached HEAD
13: Trigger deploys on Netlify with submodules
14: A Git Cheat Sheet
15: Git, squashing vs not squashing
16: An incomplete list of great Git tutorials
17: Git, what if you forgot to add a file to a commit?
18: Git workflow to manage work on multiple branches
19: How to setup the Git SSH keys