Error Collections

깃헙에러(error: src refspec master does not match any)

yunajoe 2023. 1. 9. 11:11

깃헙계정이 2개인데 다른 계정으로 commit하려다가 생긴 오류

 

에러1
error: src refspec master does not match any


해당 에러는 깃허브에서 pull 없이 push할 경우 기존 내용을 삭제하거나 하는 문제가 생길 수 있기 때문에, 
이런 문제를 피하고자 에러 메세지를 발생시키는 것. 
해당 에러가 발생하면 아래의 순서대로 다시 명령어를 입력한다. 
git init  
git add .  
git commit -m "message"

git remote add origin repo주소
git branch -M main
git push -u origin main   

에러2
remote: Permission to repo주소 denied 사용자이름
fatal: unable to access 'https://github.com/yunajoe/ProgrammersTask.git/': The requested URL returned error: 403


how to solve it?!

yunajoe@DESKTOP-ULNOHTM MINGW64 ~/Desktop/programmersTask (main)
$ git config user.name "사용자이름"

yunajoe@DESKTOP-ULNOHTM MINGW64 ~/Desktop/programmersTask (main)
$ git config credential.username "사용자이름"

===================================

yunajoe@DESKTOP-ULNOHTM MINGW64 ~/Desktop/programmersTask (main)
$ git push
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'.

=========================================== 
yunajoe@DESKTOP-ULNOHTM MINGW64 ~/Desktop/programmersTask (main)
$ git push --set-upstream origin main


==========================
출처: 
https://junheejang.tistory.com/221