[오류] Git "main and master are entirely different commit histories" ++

당근 먹는 쿼카·2022년 10월 12일
1

개발 로그

목록 보기
4/16
post-thumbnail

기존에 Git branch에서 default branch를 master라는 이름을 사용하였는데 흑인 문화를 지지하기 위해 master라는 용어가 인종차별적 인식이 될 수 있어 main이라는 이름을 사용하기 시작하였다.

그러나 여전히 VSCode의 터미널을 통해서 git을 제어하다 보면 default branch 이름이 master가 되어서 git에 push를 했을 때 main and master are entirely different commit histories 라는 문구를 Pull Request 창에서 볼 수 있다.

강제로 merge를 해도 되는 상황이라면 다음 명령어를 통해서 해결할 수 있다.

$ git checkout master
$ git branch main master -f
$ git checkout main
$ git push origin main -f

해당 명령어를 사용한 후 github repo를 확인하면 PR 요청이 사라지고 main branch에 push 한 파일이 보일 것이다.

mainmaster branch가 아니라 다른 branch로 push를 하고 싶다면 아래와 같이 하면 된다.

$ git push origin +[본인이 원하는 branch]

push 하고 싶은 branch에 +를 붙이고 Pull Request를 확인하면 오류가 사라진 것을 확인할 수 있다.

0개의 댓글