소품집

[Git] git push --set-upstream origin main 에러 해결 (브랜치 연결, remote 명시) 본문

Github

[Git] git push --set-upstream origin main 에러 해결 (브랜치 연결, remote 명시)

sodayeong 2023. 2. 14. 13:26
$ git push

git push를 할 때, 아래와 같은 에러가 나는 경우가 있음. 

이 에러는 원격 저장소에 기본 branch 설정을 안 해줬기 때문임. 

fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

방법 1. 기본 브랜치 설정

브랜치 설정을 해준 뒤

$ git push --set-upstream origin main

Everything up-to-date
branch 'main' set up to track 'origin/main'.

다시 push 하면 완료

$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 280 bytes | 280.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/sodayeong/HYTREM.git
   b44c107..131c239  main -> main

방법 2. remote 명시 

remote -v 명령어로 원격 저장소 이름을 찾은 뒤 (아래에선 origin)

$ git remote -v
origin  https://github.com/sodayeong/HYTREM.git (fetch)
origin  https://github.com/sodayeong/HYTREM.git (push)​

원격 저장소를 명시해주고 push 하면 완료

git push origin main

간단하게 git push로만 하고 싶다면 방법 1로 하면 되겠다. 

 

 

 

 

 

728x90

'Github' 카테고리의 다른 글

[Git] Gitlab 프로젝트 생성과 ssh key 적용  (2) 2020.03.28
Comments