개발

Git ) [rebase] Head가 여럿으로 나뉘었을 때 해결 방법

빠빠담 2019. 4. 10. 02:27
반응형

초기상황
rebase 와 fast-forward 이후 상황

 

과정)

1. git init을 통해 local repository를 만들고 shellscript 작성

2. shellscript 작성 후 git add, commit

 

3. github repository 생성 후 readme.md 파일 생성으로 Initial commit 으로 커밋됨

4. local repository에서 git remote add origin https://github.com/~ 으로 remote repository 연결

 

5. git fetch 로 remote repository branch 받아옴 ( origin/master )

6. git checkout -b fetchTest origin/master 로 실제 branch 생성

 

7. git merge 가 master branch, fetchTest branch 둘다 안됨

 

 

원인)

1. remote repository에 commit 이 없었으면 상관 없었으나 Init commit 으로 기록이 있음

2. local repository에서도 commit 기록이 있는 상태로 remote repository에 연결

3. 나름 conflict 상황???

4. HEAD가? 완전 따로 노는 상황

 

 

해결)

1. git checkout fetchTest

2. git rebase -i master

3. git checkout master

4. git merge fetchTest ( fast-forward )

5. git push [-f] ( 상황에 따라 pull 명령 이후 push 하자 )

6. git branch -d fetchTest

 

rebase 만 해서는 해결되지 않았다... master branch를 fast-forward 한 후 push -f 

 

 

반응형

'개발' 카테고리의 다른 글

String, getBytes  (0) 2020.05.10
Let's Encrypt - Crontab 을 이용한 자동갱신  (0) 2020.05.10
Let's Encrypt 무료 SSL 설정  (0) 2020.03.27
Docker - 명령어  (0) 2020.02.10
정규표현식 사이트  (0) 2019.06.13