How To Change Git Remote Origin – devconnected
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>.git
For example, if your repository was configured on Github, you would use the following command to change your remote.
$ git remote set-url origin git@github.com:user/repository.git
If you are having trouble identifying the URL of your Git remote on Github, the next section might be helpful.
'Programming' 카테고리의 다른 글
Pandas Tutorial (w3schools.com) (0) | 2022.04.24 |
---|---|
Pattern-defeating Quicksort (0) | 2022.04.22 |
Print Stack Trace in Python | Delft Stack (0) | 2022.04.03 |
[MySQL] ROWNUM을 사용하여 번호매기기 (0) | 2022.03.29 |
How can I display MySQL query result vertically? (tutorialspoint.com) (0) | 2022.03.24 |