IT기타
로컬소스<->git 원격 저장소 변경
emilyyoo
2025. 3. 29. 22:44
728x90
**상황 : 소스를 저장소에 연결하려는 에러가 난다.
emily-MacBook-Pro:xhtml-viewer a1$ git remote add origin https://github.com/~~~~.git
error: remote origin already exists.
**해결 : 현재 origin에 설정된 URL을 올바른 URL로 변경하려면 아래 명령어를 실행.
emily-MacBook-Pro:xhtml-viewer a1$ git remote set-url origin https://github.com/~~~.git
***연결 확인
emily-MacBook-Pro:xhtml-viewer a1$ git remote -v
origin https://github.com/~~~~.git (fetch)
origin https://github.com/~~~~.git (push)
***main 브랜치를 푸시.
git push -u origin main
--> 처음 push 할때는 아래와 같이 해줘야.
emily-MacBook-Pro:xhtml-viewer a1$ git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
728x90