Git Origin Remote URL change
Table of Contents
In order to change the Remote URL of a Git, we have to use the set-url command and specify the name of the remote as well as the new remote URL to be changed.
When we do git clone the project, automatically remote URL repository is the default origin for Push and Fetch. Now if we want to change the remote URL point to another repository then we have to update the remote URL like as follows.
Existing Remote URL:
$ git clone https://github.com/narayanatutorial/JavaMail.git $ git remote -v origin https://github.com/narayanatutorial/JavaMail.git (fetch) origin https://github.com/narayanatutorial/JavaMail.git (push)
Here remote URL is https://github.com/narayanatutorial/JavaMail.git
If we want to change the remote URL, we need to use the set-url command.
Set new Remote URL:
Syntax
$ git remote set-url <remote_name> <remote_url>
Example:
$ git remote set-url origin https://github.com/narayanatutorial/JavaMail_New.git $ git remote -v origin https://github.com/narayanatutorial/JavaMail_New.git (fetch) origin https://github.com/narayanatutorial/JavaMail_New.git (push)
Now we can push the project into the new repository JavaMail_New.git
Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in the IT industry for more than 12 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting, Website Development, and IAM(ForgeRock) Specialist
I am a self-learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.