ABOUT ME

호기심 많은 오리처럼 살아가는 사람의 블로그 입니다

Today
Yesterday
Total
  • Git push가 안되는 경우 (fatal: refusing to merge unrelated histories)
    IT, 프로그래밍/버전관리시스템(Git) 2018. 7. 13. 13:51

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


    1
    2
    3
    4
    5
    6
    7
    8
    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.
    cs



    push 전에 먼저 pull을 해서 프로젝트를 병합해 주어야 한다. 


    1
     refusing to merge unrelated histories
    cs


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


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


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

Designed by Tistory.