How To Change Git Remote Origin - Devconnected
Maybe your like
As a developer, you are probably pushing your code to your remote origin every day.
Git is a decentralized versioning system : even if you make changes locally, you have to push them to the central repository on a regular basis.
However, in some cases, you might choose to migrate your Git repository or to merge existing ones.
As a consequence, you may need to change the Git origin remote to a new URL.
In this tutorial, you are going to learn how you can change the URL of a Git remote easily.
Change Git Remote URL
In order to change the URL of a Git remote, you have to use the “git remote set-url” command and specify the name of the remote as well as the new remote URL to be changed.
$ git remote set-url <remote_name> <remote_url>For example, let’s say that you want to change the URL of your Git origin remote.
In order to achieve that, you would use the “set-url” command on the “origin” remote and you would specify the new URL.
$ git remote set-url origin https://git-repo/new-repository.git
Congratulations, you successfully changed the URL of your Git remote!
In order to verify that the changes were made, you can use the “git remote” command with the “-v” option (for verbose)
$ git remote -v
Changing Git Remote to SSH
In some cases, you may have configured your Git repository to use SSH key-based authentication.
If you want to change your Git origin remote using SSH authentication, you can use the same “git remote set-url” command but you will have to use the SSH URL in order to connect.
$ git remote set-url <remote_name> <ssh_remote_url>The SSH URL usually takes the following form :
SSH URL : git@<repo_url>:<url>/<git_repository>.gitFor example, if your repository was configured on Github, you would use the following command to change your remote.
$ git remote set-url origin [email protected]:user/repository.git
If you are having trouble identifying the URL of your Git remote on Github, the next section might be helpful.
Getting Git Remote URL on GitHub
If you need to quickly find the URL of your Git remote on Github, you first need to select your repository by navigating to your repository list.
> https://github.com/<user>/repositories
Under your repository list, select the repository you are interested in.
Now that your repository is select, locate the “Clone or Download” option on the right-corner of your screen.
Note : looking to learn how you can easily clone a Git repository? We got a complete guide written for you!
When clicking on it, you should be presented with the URL of your Git repository.

You can now use the “git remote set-url” command in order to set your Git remote URL properly (using the previous section).
Conclusion
In this tutorial, you learnt how you can easily change your Git remote URL (commonly named origin) by using the “git remote set-url” command.
You also learnt that you can change it using a password protected SSH address.
If you are looking for an easy way to generate SSH keys for Git, you should take a look at our tutorial.
SSH key authorization is preferred over password authentication, if you have a repository with a large activity.
If you are interested in Git or in Software Engineering, we have a complete guide dedicated to it on the website, so make sure to check it out!

Tag » How To Reset Git Origin
-
Git Reset Origin – How To Reset A Local Branch To Remote Tracking ...
-
Git Reset To Remote Head – How To Reset A Remote Branch To Origin
-
How To Reset A Git Branch To A Remote Repository
-
Git, How To Reset Origin/master To A Commit? - Stack Overflow
-
How To Reset Remote Origin Git Code Example - Code Grepper
-
Git And GitHub: How To Hard Reset Local And Remote Repository
-
How To Reset GIT To Origin/master? - Maslosoft
-
Git Reset Origin To Commit - Christian Engvall
-
Git Reset To Remote - Linux Hint
-
Reset And Sync Local Repository With Remote Branch - Git - OCPsoft
-
Reset Master To Match Remote - 30 Seconds Of Code
-
Managing Remote Repositories - GitHub Docs
-
Git Reset Local Branch To Remote - Linux Hint
-
Git Reset | Atlassian Git Tutorial