Git push가 안되는 경우 (fatal: refusing to merge unrelated histories)

지환·2023년 10월 30일
0

깃-오류

목록 보기
3/7
post-thumbnail

로컬 저장소에 있는 프로젝트를 깃허브 사이트를 통해 만든 저장소로 push 하는 경우에 이런 메세지가 뜨는 경우가 있다.

C:\Users\gitProject>git push origin master
To https://github.com/userId/userProject.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/userId/userProject.git'
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을 해서 프로젝트를 병합해 주어야 한다

 refusing to merge unrelated histories
cs

pull 명령 실행시 이런 문구와 함께 진행되지 않는다면, 다음의 명령으로 실행한다.

git pull origin 브런치명 --allow-unrelated-histories
cs

--allow-unrelated-histories 이 명령 옵션은 이미 존재하는 두 프로젝트의 기록(history)을 저장하는 드문 상황에 사용된다고 한다. 즉, git에서는 서로 관련 기록이 없는 이질적인 두 프로젝트를 병합할 때 기본적으로 거부하는데, 이것을 허용해 주는 것이다.

profile
아는만큼보인다.

0개의 댓글