본문 바로가기
Software Development/Git & CLI Workflow

git remote url 변경

by 병헤는 밤 2026. 3. 3.
반응형

git 레포지토리 주소가 변경 되었을때.

 

----------------------- -이 내용은 chat gpt가 답변해 준 내용입니다.

 

GitHub 원격(remote) URL을 변경하는 방법은 두 가지가 있습니다. SSH 또는 HTTPS를 사용할 수 있으며, 현재 설정된 URL을 확인한 후 원하는 방식으로 변경하면 됩니다.


1. 현재 원격 저장소 확인

먼저 현재 설정된 원격 URL을 확인합니다.

git remote -v

출력 예시:

origin  https://github.com/old-user/old-repo.git (fetch)
origin  https://github.com/old-user/old-repo.git (push)

또는 SSH를 사용하고 있다면:

origin  git@github.com:old-user/old-repo.git (fetch)
origin  git@github.com:old-user/old-repo.git (push)

2. 원격 저장소 URL 변경

(1) HTTPS로 변경

git remote set-url origin https://github.com/new-user/new-repo.git

(2) SSH로 변경

git remote set-url origin git@github.com:new-user/new-repo.git

3. 변경 확인

git remote -v

출력 예시:

origin  https://github.com/new-user/new-repo.git (fetch)
origin  https://github.com/new-user/new-repo.git (push)

또는 SSH의 경우:

origin  git@github.com:new-user/new-repo.git (fetch)
origin  git@github.com:new-user/new-repo.git (push)

이제 새로운 원격 저장소 URL이 적용되었습니다.


추가: 기존 원격 저장소 삭제 후 추가하는 방법

기존 origin을 삭제하고 새 URL을 추가하는 방법도 있습니다.

git remote remove origin
git remote add origin https://github.com/new-user/new-repo.git  # 또는 SSH URL

이후 git remote -v로 정상적으로 변경되었는지 확인하면 됩니다.


이제 변경된 원격 저장소에 git push 등을 수행할 수 있습니다. 😊

 

 

반응형

댓글