본문 바로가기
etc

한 레포지토리를 여러 폴더에 클론할 때 (Git fatal: refusing to merge unrelated histores)

by saoh 2021. 7. 24.

기존에 사용하던 사용하던 폴더가 아닌 새로운 폴더에 remote를 하여 사용하려고 하면 에러가 발생한다.

remote 를 하고 pull 명령을 주면 다음과 같은 에러가 나타나며 작업이 완료되지 않는다.

 

Git fatal: refusing to merge unrelated histores

 

기존 폴더와 관련이 없는 폴더에서 깃허브에 커밋을 하려고 하면 깃이 거부하는 것이다.

새로 사용할 폴더로 가서 git bash로 접속한 후, 관련 없는 폴더를 허용해주면 된다.

 

$ git pull origin master --allow-unrelated-histories

 

그러나 나는 에러가 또 생겼다. 

 

'origin' does not appear to be a git repository

 

내가 remote 할 때 origin이 아니라 다른 이름으로 설정해서 그렇다.

아래 명령어를 통해 내가 설정한 이름을 확인할 수 있다.

 

$ git remote -v

 

git remote -v

내가 설정한 이름은 Healthcare-sensor-interworking 이라는 것을 알 수 있다.

다시

$ git pull Healthcare-sensor-interworking master --allow-unrelated-histories

 

이제 pull을 할 수 있을 것이다 !