[ERROR] git push 에러 정리

2022. 10. 28. 19:58WEB개발/에러정리

반응형

깃허브에 커밋이 되지 않는다..!

  • 현재 위치의 폴더가 깃허브의 원격 레포지토리랑 연결이 안 돼 있다는 오류
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>

 

  • 현재위치 폴더와 원격 레포지토리 연동 후, push 명령어 사용해보기
git remote add origin <https://github.com/nanannannana/Practice.git>(레포지토리 주소)
git push --set-upstream origin main

 

  • 오류..
To <https://github.com/nanannannana/Practice.git>
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to '<https://github.com/nanannannana/Practice.git>'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 

  • 구글링해서 찾은 방법
git remote -v                 // 등록된 저장소 확인
git push origin main          // ??

 

  • 탈락!
To <https://github.com/nanannannana/Practice.git>
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to '<https://github.com/nanannannana/Practice.git>'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

 

  • 다른 방법
git push origin +main

 

  • 성공!!
  • 풀리지 않은 의문: git push origin main은 왜 오류가 나고, git push origin +main은 왜 되는 거지..?
반응형