#6. The current branch master has no upstream branch. 문제


⚠️ 문제
The current branch master has no upstream branch.

$ git push fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin master To have this happen automatically for branches without a tracking upstream, see 'push.autoSetupRemote' in 'git help config'.


🔍 원인 분석


🧐 해결 방법
git branch -m master main
git push -u origin main
# (GitHub에서 default branch 설정 변경)
git push origin --delete master   # (선택)


1. 로컬 브랜치 이름 변경하는 법

git branch -m master main

2. 원격(origin)에 새 브랜치로 푸시

git push -u origin main

3. GitHub에서 기본 브랜치를 main으로 바꾸기

  1. GitHub 웹사이트 → 해당 저장소로 이동
  2. Settings → Branches 메뉴 클릭
  3. Default branch를 master → main으로 변경

4. 기존 master 브랜치 삭제

git push origin --delete master


💡 참고

만약에 master로 계속 쓸거면 아래처럼 --set-upstream 명령어를 쓰면 된다.

git push --set-upstream origin master

이렇게 하면 origin/master 브랜치를 만들고 연결해서 master 브랜치를 원격(origin)에 푸시한다.

나처럼 지금 master 브랜치에 있고, 아직 원격 저장소에 연결되지 않았을 때,

위 명령어를 실행하면 앞으로는 git push, git pull만 쳐도 origin/master와 연결된다.





Revision #7
Created 18 May 2025 15:38:20 by Dain
Updated 18 May 2025 16:04:43 by Dain