로컬 저장소를 GitHub의 원격 저장소와 연결해보겠습니다.
먼저 GitHub에서 새 저장소를 만들어야 합니다:
+ 버튼을 클릭하고 New repository를 선택합니다.저장소가 만들어지면 다음과 같은 URL을 얻게 됩니다:
https://github.com/your-username/your-repo.git
로컬 저장소에 원격 저장소 주소를 등록합니다. origin은 원격 저장소의 별칭(alias)으로, 관습적으로 사용하는 이름입니다:
git remote add origin https://github.com/user/repo.git
잘 추가되었는지 확인하려면:
git remote -v
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)
이제 로컬 저장소의 커밋을 원격 저장소에 업로드합니다:
git push origin main
origin: 원격 저장소의 이름main: 업로드할 로컬 브랜치 이름처음 푸시할 때는 GitHub 계정 정보를 입력해야 할 수 있습니다.
다른 사람이 원격 저장소에 변경사항을 올렸다면, 다음 명령어로 내 로컬 저장소를 최신 상태로 업데이트할 수 있습니다:
git pull origin main
원격 저장소 연결 방법을 배웠습니다! 마지막 레슨에서는 협업의 핵심인 Pull Request에 대해 알아보겠습니다.
GitHub 원격 저장소를 origin이라는 이름으로 추가하세요
힌트: git remote add origin https://github.com/user/repo.git
GitHub 원격 저장소를 origin이라는 이름으로 추가하세요
$ git remote add origin https://github.com/user/repo.git