CS/git

[github] There isn't anything to compare, main and master are entirely different commit histories.

isaac.kim 2021. 5. 11.
728x90
반응형

[github] There isn't anything to compare, main and master are entirely different commit histories.

 Github에서 project repository를 하나 생성했고, 해당 repository에 프로젝트 소스코드를 commit/push 했습니다. 기존에는 제 프로젝트에 push하는 거라서 branch를 나눠서 넣지 않았기에 위 메시지가 출력되진 않았습니다. 다른 글들을 참고해보니, github 프로젝트 생성 초기 default branch name이 master에서 main으로 변경되었다고 합니다. (master-slave가 인종차별적 발언으로 인식될 수 있어서 기본 브런치를 변경했다고 함.)

 

 현재 상황은 github project의 branch는 main, 작업 환경의 branch는 master로 되어 있었고, 이상태에서 push를 하면

커밋 결과가 제대로 적용되지 않고 다음과 같은 문구가 나타납니다.

"There isn't anything to compare. main and master are entirely different commit histories."

 

 

프로젝트에 강제로 주입하는 경우 다음과 같이 해결할 수 있습니다.

$ git clone [project url]           // project 복사

$ git checkout master            // master 브런치 작업 가져오기 (덮어써짐)

$ git push origin main -f        // master 브런치 내용 main 에 강제 push

 

강제로 main에 push하여, github project에서 소스 코드가 push된 것을 확인할 수 있습니다.

 

강제로 주입할 상황이 아니라면 다른 방법을 찾아봐야 될 것 같습니다.

728x90
반응형