본문 바로가기

공부방/git

[git] 동시에 여러 작업하기

다중 branch 생성

테스트를 위하여 2개의 branch를 생성해 봅시다.

git branch issue2

git branch issue3


issue2 branch로 이동 및 branch 확인

git checkout issue2

git branch

 

issue2에서 파일을 변경하고 변경내역 저장

git add <변경한 파일>

git commit -m "issue2에서 변경하였음"


issue3 branch로 이동 후 변경 내역 저장 및 commit

git checkout issue3

git add <변경한 파일>

git commit -m "issue3에서 변경하였음"


main branch로 이동 후 issue2 브랜치 병합

git checkout main

git merge issue2


main branch에서 issue3 브랜치 병합

git merge issue3

-> 문제 발생

-> 파일내용 수정 진행

git add <변경한 파일>

git commit -m "issue3 브랜치 병합"


rebase로 issue3 브랜치 병합하기

테스트를 위하여 마지막으로 진행했던 병합 명령을 취소

git reset --hard HEAD~

 

git checkout issue3

git rebase master

-> 충돌난 파일 내용을 적절하게 변경해주자

수정해 주었다면 이번에는 commit이 아니라 rebase 명령에 --continue옵션을 지정하여 실행해야 한다.

git add <수정한 파일>

git rebase --continue

 

git checkout main

git merge issue3

 

 

'공부방 > git' 카테고리의 다른 글

[Git] Git HEAD, reset 옵션 3가지 (hard, mixed, soft)  (0) 2022.12.20
Github을 잘 사용해보자! (Issue와 commit)  (0) 2022.04.30
Git 작업관리  (0) 2022.04.30
[git] 브랜치 사용하기  (0) 2021.07.13
[git] 기본 명령어  (0) 2021.07.13