반응형
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 등을 수행할 수 있습니다. 😊
반응형
'Software Development > Git & CLI Workflow' 카테고리의 다른 글
| 삭제 안되는 파티션 삭제 방법 (diskpart 이용) (0) | 2026.02.11 |
|---|---|
| 로그파일에서 일시를 UTC->KST 로 변환 하여 표시 하는 방법. (0) | 2024.09.24 |
| Intellij를 터미널 창에서 실행하기 (맥OS) (0) | 2024.03.20 |
| vue.js not detected 오류 해결 방법 (0) | 2023.05.02 |
| vscode에서 기본 html 양식 설정 하는 방법 (0) | 2023.05.02 |
댓글