몰입하는 개발자

An immersive developer/researcher

개발자 김모립/Git

Git branch 관리

jiankimr 2023. 7. 7. 12:35

<최신 master branch 내용 가져오기>
1. git checkout master
(master branch로 이동)
2. git pull origin master
(github master branch 내용 가져오기)

<브랜치 생성 후 옮기기>
1. git branch "브랜치 이름"
(브랜치 만들기)
2. git checkout "브랜치 이름"
(해당 브랜치로 이동)

<본인 브랜치에서 작성한 코드 github에 업로드>
1. git checkout "브랜치 이름"
(해당 브랜치로 이동)
2. git add .
3. git commit -m "메세지"
4. git push origin "브랜치 이름"
(github에 해당 브랜치로 업로드)

<master 브랜치에 합치기(merge)>
1. git checkout master
(master 브랜치로 이동)
2. git merge "브랜치 이름"
(코드 충돌이 일어날 경우 침착하게 대처)
3. git add .
4. git commit -m "메세지"
5. git push origin master
(github에 합친 코드를 업로드)

<브랜치 삭제: 보통 merge 직후>
1. git checkout master
(삭제될 branch에 checkout되어있으면 안되기 때문)
2. git branch -d "브랜치 이름"
(로컬 브랜치 삭제)
3. git push --delete origin "브랜치 이름"
(원격 브랜치 삭제)

<브랜치 목록 확인하기>
1. git branch -a
(로컬, 원격 브랜치 목록 확인)