This article will provide
So, let’s begin!
How to Change Git Remote Origin Using HTTPS URL?
To change a Git remote origin using an HTTPS URL, first, open the Git terminal and check the existing remote URL. Next, switch to the remote repository and copy the HTTPS URL. Then, execute the “$ git remote set-url origin <https-url>” command to set the new origin.
Now, let’s move toward the implementation of the above-discussed scenario!
Step 1: Check Remote Origin(URL)
Run the below-provided command to view the existing remote origin:
Step 2: Copy HTTPS URL
Next, open up the desired remote repository, click on the below-highlighted button and copy the HTTPS URL:
Step 3: Set Remote Origin(URL)
Finally, set the remote origin by utilizing the “git remote set-url origin” command with the copied URL:
Step 4: Verification
Lastly, verify the set remote origin through the following command:
It can be seen that the new remote origin(url) is changed successfully:
Let’s check out the next section to change the remote origin using the SSH URL.
How to Change Git Remote Origin Using SSH URL?
Git users can change the remote origin using the SSH URL. To do so, copy the SSH URL of the Git remote repository. Then, run the “$ git remote set-url origin <https-url>” command to set the new origin using the SSH URL.
Step 1: Copy SSH URL
To copy the SSH URL, go to the remote repository, press the “Code” button, and click on the provided SSH URL:
Step 2: Change Remote Origin
Now, execute the “git remote set-url origin” command with copied SSH URL to change the existing remote origin:
Step 3: Verify Changed Origin(URL)
To verify the changed remote origin, run the following command:
According to the below output, the remote origin is changed successfully:
That’s it! We have offered the easiest methods to change the remote origin using HTTPS and SSH URLs.
Conclusion
Users can change the remote using HTTPS or SSH URLs. For this purpose, first, check the existing remote origin. Then, switch to the GitHub hosting service and copy the required remote repository URL. Lastly, execute the “$ git remote set-url origin <remote-url>” command to update the remote origin. This manual demonstrated changing the remote origin using HTTPS and SSH URLs.