$ git push <remote> <branch>
위 명령어를 사용하면 local branch를 원격 저장소로 push 할 수 있습니다.
이때 만약 upstream이 설정되어 있다면 git push 명령으로 단순하게 push 할 수 있습니다.
여기서 말하는 upstream은 local branch가 추적(trace)할 원격 branch를 의미합니다.
upstream 설정
$ git push -u <remote> <branch>
or
$ git push --set-upstream <remote> <branch>
upstream을 설정하는 방법은 push의 옵션인 -u(또는 --set-upstream)을 사용하면 설정할 수 있습니다. 해당 방식은 upstream 설정과 동시에 push 동작도 실행됩니다.
$ git branch --set-upstream-to=<remote>/<target branch> <local branch>
위 명령어를 사용하면 upstream 설정만 할 수 있습니다.
upstream 확인
$ git branch -vv
설정된 upstream을 보기 위해서는 위 명령어를 사용하면 아래 사진과 같은 결과가 나옵니다.
위 사진에서 보면 [origin/main]이라고 쓰여있는 부분이 upstream이 설정되어 있는 것을 확인할 수 있는 부분입니다. upstream 설정이 되어있지 않다면 feature/change-icon처럼 아무런 표시가 나타나 있지 않습니다.
upstream의 설정은 필수는 아니지만, 설정을 통해 추적 관계를 만들어 놓으면 명령어를 사용하거나 관계를 볼 때도 편리하기 때문에 설정하는 것을 추천합니다.
upstream 변경
$ git branch --set-upstream-to=<remote>/<branch>
기본 브랜치의 이름이 바뀌었거나 다른 원격 브랜치를 추적하려면 위 명령어를 사용해서 upstream을 변경할 수 있습니다.
upstream 해제
마지막으로 upstream 설정을 해제하는 것으로 마무리하겠습니다.
$ git branch --unset-upstream <branch>
위 명령어를 통해 설정된 upstream을 해제할 수 있습니다.
'개발' 카테고리의 다른 글
[Npm] how to update npm to the latest version? 최신 버전으로 npm 업데이트 하기 (0) | 2025.03.27 |
---|---|
[Sub Issue] Use pragmatic-drag-and-drop-react-beautiful-dnd-migration (0) | 2025.03.27 |
[Issue] Migrate react-beautiful-dnd to pragmatic-drag-and-drop (0) | 2025.03.25 |
[Github] What is sub issue(sub issue가 뭐여)? (0) | 2025.03.25 |
[VSCode 꿀팁] PDF 파일 열어보기 (0) | 2025.03.21 |