문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판이전 판다음 판 | 이전 판 | ||
| git:remote [2023/04/20 13:31] – taekgu | git:remote [2025/04/15 10:05] (현재) – 바깥 편집 127.0.0.1 | ||
|---|---|---|---|
| 줄 1: | 줄 1: | ||
| + | ====== 원격저장소 관리하기 ====== | ||
| + | ===== 원격저장소추가 ===== | ||
| + | ==== 1.기존 원격 저장소 그대로 두고 추가하는 방법 ==== | ||
| + | 또 다른 이름으로 remote를 추가 해 줍니다. second 라는 이름으로 추가 한다고 가정하면 아래 명령어 처럼 입력합니다. | ||
| + | |||
| + | <code bash> | ||
| + | git remote add second git@github.com: | ||
| + | </ | ||
| + | ==== 2.기존 원격 저장소 이름을 old-origin으로 변경하고 origin으로 추가하는 방법 ==== | ||
| + | |||
| + | <code bash> | ||
| + | git remote rename origin old-origin | ||
| + | git remote add origin git@github.com: | ||
| + | git push -u origin --all | ||
| + | git push -u origin --tags | ||
| + | </ | ||
| + | ==== 3.기존 원격저장소를 삭제하고 새로 추가하는 방법 ==== | ||
| + | |||
| + | <code bash> | ||
| + | git remote remove origin | ||
| + | git remote add origin git@github.com: | ||
| + | </ | ||
| + | |||
| + | 저는 기존의 원격 저장소가 필요 없어서 3번을 선택 했습니다. 여러개의 원격 저장소가 추가된다면 혼동이 올 수도 있습니다. | ||
| + | |||
| + | ====== 소스 반영 ====== | ||
| + | 그냥 git push를 했더니 upstream branch가 설정되어있지 않기 때문에 에러가 발생했습니다. | ||
| + | |||
| + | <code bash> | ||
| + | git push | ||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | % git status | ||
| + | On branch master | ||
| + | nothing to commit, working tree clean | ||
| + | % git push | ||
| + | fatal: The current branch master has no upstream branch | ||
| + | To push the current branch and set the remote as upstream, use | ||
| + | |||
| + | git push --set-upstream origin master | ||
| + | |||
| + | % | ||
| + | </ | ||
| + | |||
| + | ===== set-upstream -u ===== | ||
| + | |||
| + | <code bash> | ||
| + | git push -u origin master | ||
| + | # -u 옵션은 local repository의 branch를 local repository branch에 연결하기 위한 것, 처음 한번만 쓰면 된다. | ||
| + | # -u 옵션을 붙이면 다음부터 git push 명령만으로 원격 저장소의 master 브랜치에 커밋을 올릴 수 있다. | ||
| + | </ | ||
| + | |||
| + | 어렵다. | ||