[Git] 오류 해결 git push --set-upstream origin main

Sunow·2023년 11월 8일
0

Git

목록 보기
2/2
post-thumbnail



🚨 오류 발생

$ git 
  • clone해 온 파일을 수정한 뒤 push 했더니 아래와 같은 에러 발생

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'.
  • 해당 오류는 원격 리포지토리에 대한 upstream branch를 설정하기 않았을 때 발생한다.

  • 업스트림 브랜치(upstream branch) : 로컬 브랜치가 원격 리포지토리의 어떤 브랜치를 따라가는지를 나타냄




✅ 해결 방법

업스트림을 설정해준다.


$ git push --set-upstream origin main

Enumerating objects: 9, done.
Delta compression using up to 16 threads
Total 7 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
   187ae64..bd7190f  main -> main
branch 'main' set up to track 'origin/main'.

위의 명령을 사용하면 현재 브랜치를 원격 리포지토리의 'main' 브랜치와 연결하고, 그 브랜치를 추적하도록 설정할 수 있다.


$ git push

Everything up-to-date

이후에는 원래대로 'git push' 명령만 사용해도 설정한 원격 브랜치로 푸쉬할 수 있다.





참고 : https://sodayeong.tistory.com/223

0개의 댓글