git

git remote url 변경

rachel_13 2022. 10. 27. 02:14

한 대의 PC로 회사 계정과 개인 계정을 사용하다보니 ssh로 설정을 해두었다.

그러다가 개인 계정의 아이디를 바꾸면서 config 설정도 변경해주고, 로컬환경에서 작업 후 push를 시도했는데, 

아래와 같은 오류가 발생하였다.

 

 Could not resolve hostname github.com nodename nor servname provided, or not known 

 

[해결 방법]

1. remote 주소 확인

git remote -v

2. 주소 변경 (이때 config 설정과 동일하게 해야함)

git remote set-url origin https://github.com/레포지토리명.git

// ssh로 접속하도록 설정한 경우
git remote set-url origin git@github.com:계정ID/레포지토리명.git

//config 설정을 추가로 했을 경우(회사계정, 내 계정 등 여러 계정으로 분기처리가 되어있을 때)
git remote set-url origin git@github.com-(config에서 설정된 이름):계정ID/레포지토리명.git
ex) git remote set-url origin git@github.com-work:계정ID/레포지토리명.git