[git] push / pull할 때, "fatal: refusing to merge unrelated histories" 에러 해결 방법.

2023. 2. 9. 14:00Tool/git

728x90
728x90

remote repository 데이터를 local repository pull , "fatal: refusing to merge unrelated histories" 에러 발생하는 것을 확인.

tmax@DESKTOP-TK7E03C MINGW64 /d/localRepository (master)
$ git pull origin main
warning: redirecting to https://192.168.123.123/root/anylink_t.git/
From https://192.168.123.123/root/anylink_t
 * branch            main       -> FETCH_HEAD
fatal: refusing to merge unrelated histories

발생 원인.

  • 로컬 프로젝트와 원격 저장소가 관련이 없는 독립적인 프로젝트로 깃이 인식하는 경우에 발생함.

해결 방법.

  • $git push ... / $ git pull ... 을 수행할 때, "--allow-unrelated-histories" 옵션 추가.
$ git pull origin main --allow-unrelated-histories
728x90
728x90

'Tool > git' 카테고리의 다른 글

[git] git 개념 정리.  (0) 2023.08.01