[Git] fatal: refusing to merge unrelated histories
에러 상황
로컬 git 저장소를 생성하고 Github에도 저장소를 만들어서 연결한다.
$ git remote add origin https://github.com/GunwooYun/Crypttto.git
Github에서 README.md를 만들었으니 git pull 을 이용해 origin과 동기화한다.
위와 같이 fatal: refusing to merge unrelated histories 에러가 발생한다.
블로그 검색 결과, 로컬 저장소와 원격 저장소간의 history가 관련이 없기 때문에 (마치 전혀 다른 repository) pull->merge 가 불가하다고 한다. 그래서 "unrelated histories" 라고 나오는 듯 하다.
방법은 다음과 같다.
1. 처음에 README.md를 만들지 않은 clean한 저장소를 연결해서 쓰던가 (시도해보진 않음)
2. 원격 저장소를 clone하고 해당 디렉토리를 프로젝트 디렉토리로 설정해서 쓰던가 (이렇게 보통 씀)
3. git pull origin (branchname) --allow-unrelated-histories 를 실행해서 pull 하던가
3번 방법으로 pull을 진행했고, 다행히 잘 merge 되었다.
이후 첫 커밋의 push도 잘 실행된다.
참고 블로그: https://jobc.tistory.com/177
git push, pull (fatal: refusing to merge unrelated histories) 에러
원격 저장소를 remote로 설정하고 바로 push를 하면 몇가지 오류가 발생할 수도 있다.예를 들어 아래와 같은 오류 메시지이다.12 ! [rejected] master -> master (non-fast-forward)error: failed to push some refs to 'https:
jobc.tistory.com