728x90
728x90

원격 저장소 주소 변경하는 방법

들어가며

  • Git 명령어를 이용하여 현재 프로젝트의 원격(Remote) 저장소 주소를 변경하는 방법을 정리해본다.

 

방법

현재 원격 저장소주소 확인하기

  • 현재 프로젝트에 연결된 원격 저장소 주소를 확인한다.
$ git remote -v
origin https://github.com/old-user/old-repo.git (fetch)
origin https://github.com/old-user/old-repo.git (push)

 

 

현재 원격 저장소 주소 변경하기

  • set-url 옵션을 사용하여 원격 저장소 주소를 변경할 수 있다.
$ git remote set-url origin <새로운_원격_저장소_주소>

 

사용 예
$ git remote set-url origin https://github.com/new-user/new-repo.git

 

  • 그리고 원격 저장소 주소가 변경되었는지 확인한다.
$ git remote -v
origin https://github.com/new-user/new-repo.git (fetch)
origin https://github.com/new-user/new-repo.git (push)

 

새로운 원격 저장소 주소 테스트하기

  • 새로운 원격 저장소가 정상적으로 작동하는지 확인한다.
$ gut push origin main

 

SSH 키를 사용하는 경우, SSH URL 형식(git@github.com:username/repository.git)을 사용 한다.

 

참고 사이트

 

How do I change the URI (URL) for a remote Git repository?

I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved "origin" to a NAS and successfully tested cloning it from here. I would like to know if I can change th...

stackoverflow.com

 

728x90
728x90

원격 저장소 주소 변경하는 방법들어가며방법현재 원격 저장소주소 확인하기현재 원격 저장소 주소 변경하기새로운 원격 저장소 주소 테스트하기참고 사이트