분기된 branch로 작업할때 master branch에 업데이트 된 내용을 분기 된 branch에 업데이트할 필요가 있다.
그럴 때 master branch로 rebase를 해주면 update 해줄 수 있다.
git rebase -i origin/master
다음과 같은 명령어를 입력하면 vi 편집기가 열리고 편집기에는 commit list와 command 에대한 설명이 나와있습니다.
이때 pick을하면 해당 commit을 사용하고 drop 하면 해당 커밋은 삭제되게 되어서 commit 관리 또한 해줄 수 있습니다.
만약 충돌이 발생하게되면 충돌 파일을 수정한 후 git add 를 해주고 git rebase --continue를 입력하여서 다음 commit을 적용시키도록 합니다.
Rebase가 완료되면 'Successfully rebased and updated (브랜치이름).' 메시지가 뜨게됩니다.
만약 여기서 git pull 을 하라는상태가 떠서 pull을 할경우 충돌이 발생할 수 있으니 로컬 브랜치로 push를 해주어야한다.
그렇게 되면 rebase 가 완료된다.
참조/출처
https://stackoverflow.com/questions/31069316/error-with-git-rebase-could-not-apply/42084346
Error with git rebase ("could not apply...")
I'm the administrator of the GitHub repository https://github.com/plison/opendial. I would like to reduce the number of commits on the repository, since the repository already has a few thousand co...
stackoverflow.com
https://victorydntmd.tistory.com/279
[Git] 명령어(6) - rebase ( merge와 비교, --interactive 옵션 )
1. rebase rebase는 merge처럼 병합하는 작업이지만, 커밋 이력을 다룰 수 있다는 점에서 차이가 있는데요. ( merge와 rebase 비교 - 참고 ) 불필요한 merge 이력을 남기지 않기 때문에, Git은 rebase를 통해 병합..
victorydntmd.tistory.com
'프로그래밍 > Git' 카테고리의 다른 글
[Git] commit message (0) | 2019.10.01 |
---|---|
[Git] 원격저장소 & branch (0) | 2019.09.03 |