[Git] default branch를 main으로 바꾸는 법

오도원공육사·2021년 7월 30일
0

git

목록 보기
1/5

10월 이전의 설치한 git version에 대하여 git init을 통해 git 저장소를 생성하면 처음 default branch는 master로 된다.

1. 로컬 저장소 default branch 변경하기


git config command를 사용하는 것이다.

git config --global init.defaultBranch main

이후로 git init을 통해 로컬에서 생성하는 repo의 default branch는 main으로 생성된다.

2. remote repo의 default branch 변경하기


remote repo의 default branch는 setting → branches → default branch에서 변경할 수 있다.

3. 이미 생성된 프로젝트의 default branch 변경하기


기존의 master branch를 쓰는 로컬 저장소를 main으로 변경해보자. git config --global init.defaultBranch main을 했어도 이전의 생성된 repo는 default branch가 master로 되어있을 것이다.

  1. default branch 확인
git config init.defaultBranch
// master
  1. default branch 변경
git config init.defaultBranch main
  1. 현재 branch 명 변경
git branch -m master main
profile
잘 먹고 잘살기

0개의 댓글