[Git] git branch 생성

강신현·2022년 1월 13일
0

[프로젝트/UMC] INFRA

목록 보기
1/11
post-thumbnail

umc(앱 런칭 동아리)에서 본격적으로 다른 개발자와의 협업을 시작했다.
협업으로는 처음이라 많이 헷갈린다. 정리해두고 헷갈릴때마다 꺼내보자!

개요
1. clone, remote
2. branch 생성
3. 생성한 Branch를 push

1. clone

github repository를 내 local로 clone한다.

git clone (github에서 복사한 주소)

현재 위치한 branch 확인

git branch

원격 저장소의 branch 확인

git branch -r

2. branch 생성

git branch (생성할 branch 이름)

생성됨을 확인 했으니, 생성한 branch로 이동
(브랜치 이동을 하기 전에 꼭 pull을 받도록..!)

git checkout (이동할 branch)

3. 생성한 Branch를 push

git push

로컬 레포에는 branch가 있지만 원격 레포에는 branch가 없는 상태 이므로, 처음 push할때는 다음과 같이 설정해줘야 한다.

git push --set-upstream origin (branch)
git push -u origin (branch)

(둘중 아무거나 사용하면 됨)

shinhyeon branch가 추가된 모습

참고
https://wayhome25.github.io/git/2017/07/08/git-first-pull-request-story/
https://goddaehee.tistory.com/274

profile
땅콩의 모험 (server)

0개의 댓글