• Modern UX

    Edit and navigate faster in the terminal with Warp's IDE-like input editor.

  • Warp AI

    AI suggests what commands to run and learns from your documentation.

  • Agent Mode

    Delegate tasks to AI and use natural language on the command line.

  • Warp Drive

    Save and share interactive notebooks, workflows, and environment variables.

  • All Features

Change Git Origin Remote URL

Thumbnail for Philip WilkinsonPhilip Wilkinson

Philip Wilkinson

Software Engineer, Amazon

Published: 11/30/2023

About Terminus

In this post, we will deal with changing the remote git repository associated with a local git-enabled directory.

If you are here and don’t yet have a git repository set up, read about creating a git repository to get started, and then pushing a local repository to a remote origin. At that point, you will have your upstream set and can proceed with the following command to update the origin:

 git remote set-url origin <url>

Run in Warp

Spare yourself remembering the syntax with a Warp Workflow to do this

If you are using Warp as your terminal and you want to quickly retrieve the command to change the remote url of your local git repository, you can use Warp’s Workflow feature by pressing CTRL-SHIFT-`, typing change url of remote git repository, then pressing ENTER to use the suggested command:

Thumbnail for

All you then have to do is enter the new desired remote url and it should be changed!

Good reasons to consider changing your remote URL

Here are some examples of situations where changing your remote URL makes sense:

  1. 1. Switching from HTTP to SSH: This can provide better security and authentication as well as fast connection speeds. This should not affect the state of the remote repository or impact the interaction with your co-workers but can make your work more secure. To learn more about using Git with SSH, you can read our post on how to clone, push, and pull on a remote git repository with ssh.
  2. 2. Moving to a new hosting provider: Such as from GitHub to GitLab will require a change of URL. This is likely to affect your coworkers as they will also have to change their remote URL.
  3. 3. Renaming your repository: This will require a URL change to reflect the new repository, which all your coworkers will also need to change.
  4. 4. Updating credentials: If your authentication details have changed (e.g. password) then you may need to update the URL to reflect that. In some cases however this may only affect your local credentials, not the URL.

Generally, changing the URL of a remote repository is a relatively simple and harmless process, but it is important to ensure that all team members are aware of the change to avoid any disruptions in workflow. 

Connecting to a remote repository

To connect a local git-enabled repository to a remote repository, you can use the following command:

 $ git remote add <name> <URL>

Run in Warp

Where name is an alias for the remote repository that can be used to interact more easily with it. This includes git push or git pull, where you can use 'name' instead of the repository's URL. The most commonly used one is origin.

And URL is the URL of the remote repository that often takes the form git@<host>:<username>/<repository>.git. For example: [email protected]:johndoe/my-app.git.

To verify that your local repository has successfully been connected to a remote repository, you can use the following command:

 $ git remote -v

Run in Warp

Which should print the remote URL the local repository is connected to.

Changing a remote repository URL

A common use case for changing a remote repository URL is when you want to switch from HTTPS to an SSH connection as it is considered more secure and efficient, especially for repositories that you need to interact with frequently.

To change the remote URL of a connected Git repository you can use the following command:

 $ git remote set-url origin <new_url>

Run in Warp

Where origin is the name of the remote repository you want to modify and new_url is the new URL you want to connect the Git repository to.

To check that the new remote has been successfully set, you can once again use the following command:

 $ git remote -v

Run in Warp

Written by

Thumbnail for Philip WilkinsonPhilip Wilkinson

Philip Wilkinson

Software Engineer, Amazon

Filed Under

Related Articles

Undo A Git Pull

How to effectively remove the commits introduced by a pull in Git using git-reset and preserve your local changes using git-stash. Also, how to cancel an unmerged pull request on GitHub.

Git
Thumbnail for Glory KimGlory Kim

Undo a Git Merge

How to rollback the changes introduced by a merge in Git by adding new opposite commits using git-revert and effectively removing commits using git-reset.

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Prompt Show Git Branch In Prompt

Enhance your terminal with a custom Git prompt. Learn different ways to integrate this contextual info, from custom shell functions to Warp context chips and toolkits like Starship and P10K.

Git
Thumbnail for Gabriel ManricksGabriel Manricks

How To Remove Secrets From The Git History Remove Secrets From The Git History

Learn how to remove secrets from the Git history using the BFG and git-filter-repo command-line tools.

Git
Thumbnail for Utsav PoudelUtsav Poudel

Adding a Submodule in Git

This post will show you how to simply add a submodule to a local repository, clone a repository with a submodule, and work within a repository that has a submodule.

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Undo a git push

This post will show you had to simply undo a git push three different ways.

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Undo Git Add

Learn how to effectively use 'git add' to stage files in Git for committing, and discover two powerful methods to undo accidental stagings.

Git
Thumbnail for Glory KimGlory Kim

Undo a Git Rebase

This post will show you how to undo a rebase using git reset, git rebase and git revert

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Git Push Origin

A breakdown of git push origin

Git
Thumbnail for Amanda KhooAmanda Khoo

Create Folder In GitHub Repository

Learn how to create and push one or more empty directories in a Git repository using `.placeholder` and `README.md` files using both the CLI and the GitHub interface.

Git
Thumbnail for Razvan LudosanuRazvan Ludosanu

Git Push Tags

This post will show you how to push a single tag, multiple tags, all tags, and tags with commits.

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Undoing Git Commits

Explore ways to undo a commit, including git reset, git checkout, and git revert with git while preserving commit history.

Git
Thumbnail for Philip WilkinsonPhilip Wilkinson

Trusted by hundreds of thousands of professional developers

Download Warp to get started

Download for Mac
Thumbnail for null