로컬의 파일들을 깃허브 저장소로 push 하는 경우에 아래와 같은 오류가 뜨는 경우가 있다.

$ git push origin master
To https://github.com/nuatmochoi/wifi-collector
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/nuatmochoi/wifi-collector'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

push하기 전에 pull을 통해 프로젝트를 병합하는 과정이 필요하다.

아래와 같은 메세지와 함께, pull 명령이 작동하지 않는다면,

fatal: refusing to merge unrelated histories

--allow-unrelated-histories 옵션을 통해 해결 가능하다.

신규 프로젝트와 기존 프로젝트가 같은 조상을 보고 있기 않기 때문에, git은 본질적으로 다른 프로젝트로 인식하고, 이것을 허용하며 병합시키는 데 사용되는 옵션이다.

git pull origin master --allow-unrelated-histories

+ Recent posts