[Git] 깃 오류 해결 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

지환·2023년 10월 4일
0

깃-오류

목록 보기
2/7

출처 | https://healthcoding.tistory.com/18

깃을 처음 설치하고 로컬 저장소와 원격 저장소를 만들어서 푸시 테스트할 때 가끔 이런 메시지를 볼 수 있다.

$ 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

오류의 원인은 처음 만들고 원격 저장소에 대한 기본 브랜치 설정을 안 해줬기 때문이다.

이런 오류는 처음 브랜치 설정만 해주면 간단하게 해결이 가능하다.

$ git push --set-upstream origin master

이렇게 코드를 입력하면,

$ git push --set-upstream origin master
...
To https://url-to-remote-origin
   1561943..f8357d9  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

그 후 다시 푸시를 하게 되면

$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 349 bytes | 349.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
To https://url-to-remote-origin
   f8357d9..c29db9a  master -> master

해결가능하다.

profile
아는만큼보인다.

0개의 댓글