Git - master를 main으로 바꾸는 문제

jswboseok·2023년 3월 6일
0

github repository나 처음 git을 연동시킬 시 기본 branch 명은 master였는데, 이게 과거 노예제도를 연상시킨다 해서 master라 하지 않고 main으로 바꾸도록 권장하고 있다.

로컬에서 git init을 한 후 커밋을 하면 기본 branch 명이 master가 된다. 이 때, 바로 git push origin master를 하게 되면 github repository에 main과 master 두 개의 branch가 생성되는데, 이게 merge를 하기 까다롭다 (내가 못하는거일수도…). 그래서 그냥 처음부터 로컬에서 이름을 master에서 main으로 바꾸는 것이 좋은 것 같다. 아래 블로그를 참고하였다

https://velog.io/@kimiszero/github-src-refspec-master-does-not-match-any-%ED%95%B4%EA%B2%B0%EB%B0%A9%EB%B2%95

git init
git branch -m main
git remote add origin "github.com/your_ropo.git"
git add .
git commit -m "first commit"
git push -u origin main

git branch -m main을 통해 이름을 master에서 main으로 변경해준다.

profile
냠냠

0개의 댓글