본문 바로가기

개발 이야기

[git error] refusing to merge unrelated histories

 

 

[git pull error : refusing to merge unrelated histories]

 

1. 먼저 'git push' 하려고 하니, 'git pull ....'을 먼저 하라는 오류 메세지를 받고, 'git pull origin [브랜치명]'을 입력했더니 다음과 같은 오류가 발생했다. (나는 안드로이드스튜디오에서 발생했다.)

 

refusing to merge unrelated histories

 

2. 원격 저장소(git)의 내용을 가져와야 하는데, 원격 저장소와 로컬 저장소의 내용이 너무 다를 경우 발생하는 오류이다.

 

[해결방법]

 

1. 아래와 같은 명령을 입력해준다.

 

allow-unrelated-histories

 

뒤에 [--allow-unrelated-histories]는 원래 git에서는 서로 다른 파일을 병합할 수 없는데, 그것을 무시하고 강제로 병합하게 해주는 속성이다.

 

 

* 만약 위와 같이 했는데도 충돌이 일어난다면, 그냥 다시 clone해서 시작하는 것도 방법이다..