(내일배움캠프) TIL(20) - 9주차: 원격저장소에서 특정 브랜치 가져오기

Thomas·2023년 7월 18일
0
post-thumbnail

첫 프로젝트 세팅시 배포용 main에 feature 병합용으로 develop 브랜치를 만들었을 때
로컬에는 적용이 안 되어 있어서 로컬에 적용하고 feature를 develop 브랜치에서 생성 하는 방법을 알게 되어서 기록을 남기게 되었다.

가장 먼저 원격저장소랑 인텔리제이의 원격저장소랑 매치를 시켜줘야 한다

git remote update

그다음으로 원격저장소의 브랜치 목록을 조회한다

git branch -r

원하는 브랜치를 로컬에 가져온다

git checkout -t origin/develop

-t, --track
When creating a new branch, set up "upstream" configuration. See "--track" in git-branch(1) for details.
If no -b option is given, the name of the new branch will be derived from the remote-tracking branch, by looking at the local part of the refspec configured for the corresponding remote

-t는 새 분기를 만들 떄 "업스트림" 구성을 설정한다
-b 옵션을 안 넣었기 떄문에 새 분기의 이름은 해당 원격으로 설정이 된다!

그러면 최종적으로 develop 브랜치로 checkout된 모습을 볼 수 있다!!

profile
Backend Programmer

2개의 댓글

comment-user-thumbnail
2023년 7월 18일

좋은 글 잘 읽었습니다, 감사합니다.

1개의 답글