나눔노트

git 저장소 주소 변경하기 본문

개발

git 저장소 주소 변경하기

킁한국인 2025. 4. 28. 13:14

Git 저장소의 원격(remote) URL을 변경하는 방법은 크게 두 가지가 있습니다. 아래 예시를 참고하세요.


1. git remote set-url 사용

  1. 현재 설정된 원격 URL 확인
    origin  https://old.repo.url/path/to/repo.git (fetch)
    origin  https://old.repo.url/path/to/repo.git (push)
    
  2. git remote -v
  3. 원격 URL 변경
  4. git remote set-url origin https://new.repo.url/path/to/repo.git
  5. 변경된 URL 확인
    origin  https://new.repo.url/path/to/repo.git (fetch)
    origin  https://new.repo.url/path/to/repo.git (push)
    
  6. git remote -v

2. remove + add 방식

  1. 기존 원격 제거
  2. git remote remove origin
  3. 새 URL로 다시 추가
  4. git remote add origin https://new.repo.url/path/to/repo.git
  5. 확인
  6. git remote -v

SSH URL로 변경할 때

  • HTTPS 대신 SSH를 쓰고 싶다면, URL만 바꿔주세요:
  • git remote set-url origin git@github.com:username/repo.git

복수의 원격이 있을 경우


이렇게 하면 로컬 저장소가 새 원격 저장소를 가리키게 됩니다. 이후 git push, git pull 모두 새 URL을 통해 작동합니다.

'개발' 카테고리의 다른 글

Rust 언어의 탄생 배경  (1) 2025.04.28
CRUD 란?  (0) 2023.12.10
Gitea git 서버 구축  (3) 2023.09.08