문제상황
local에서 react프로젝트를 만들었다. 그리고 깃헙에 빈 repository를 하나 만들고, local의 remote에 해당 repository를 추가했다. 이제 local에서 작업한 것들을 push하면 되는데,,,
git push origin main
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/rpf5573/react-without-create-react-app.git'
뭔말이지? refspec main???
해결방안 찾기
싹다 다시하기
.git
폴더를 삭제하고 다시 git init, commit, push
해보자
안된다 똑같다.
master? main?
최근에 github은 핵심 branch의 이름을 master에서 main으로 바꿨다. 근데 내가 git show-ref
를 해보니까, e3d425f7d2b6bf7b4eea387ec0b7d525a2d2d558 refs/heads/master
이렇게 나왔다. 다시말해 master를 가리키고 있는것이다..,main이 아니라!
찾아보니까 git을 initialize할때 default branch name을 설정할 수 있도록 되어있다!
git init --initial-branch=main
--혹은--
git init -b main
했더니 이번엔 다른 문제가…
To https://github.com/rpf5573/react-without-create-react-app.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://github.com/rpf5573/react-without-create-react-app.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.