GIT에서 커밋을 푸시 할 때 'SRC REFSPEC 마스터가'일치하지 않습니다 '라는 메시지가 일치하지 않습니다.


질문

 

내 저장소를 복제합니다.

git clone ssh://xxxxx/xx.git 

그러나 일부 파일을 변경하고 추가하고 커밋 한 후에는 서버에 밀어 넣고 싶습니다.

git add xxx.php
git commit -m "TEST"
git push origin master

그러나 내가받는 오류는 다음과 같습니다.

error: src refspec master does not match any.  
error: failed to push some refs to 'ssh://xxxxx.com/project.git'

답변

 

어쩌면 당신은 단지 저지를 필요가있을 것입니다.내가 할 때 나는 이것을 달렸다 :

mkdir repo && cd repo
git remote add origin /path/to/origin.git
git add .

죄송합니다!결코 헌신하지 않았다!

git push -u origin master
error: src refspec master does not match any.

내가해야 할 일은 모두 :

git commit -m "initial commit"
git push origin master

성공!



답변

  1. Try git show-ref to see what refs you have. Is there a refs/heads/master?

최근의 "Main in Github"조치로 마스터를 교체하십시오.결과적으로 다음 명령은 Git Push 원점 헤드에서 변경 될 수 있습니다 : 마스터 눌러 푸시 원점 헤드 : Main

  1. You can try git push origin HEAD:master as a more local-reference-independent solution. This explicitly states that you want to push the local ref HEAD to the remote ref master (see the git-push refspec documentation).


답변

또한 로컬 컴퓨터의 모든 파일을 삭제 한 후에도 비슷한 오류가 있었으며 저장소의 모든 파일을 정리해야합니다.

내 오류 메시지는 다음과 같았습니다.

error: src refspec master does not match any.
error: failed to push some refs to 'git@github ... .git'

다음 명령을 실행하여 해결되었습니다.

touch README
git add README

git add (all other files)
git commit -m 'reinitialized files'
git push origin master --force  # <- caution, --force can delete others work.


답변

git push -u origin master
error: src refspec master does not match any.

이를 위해 다음과 같이 커밋 메시지를 입력하고 코드를 푸시해야합니다.

git commit -m "initial commit"

git push origin master

성공적으로 마스터에게 푸시했습니다.



답변

나를 위해 공개 키가 서버 (~ / .ssh / authorized_keys에 추가)와 github / bitbucket (github 또는 bitbucket에 ssh 키에 추가됨)에 공개 키가 올바르게 구성되었는지 확인해야했습니다.그 다음에:

git add --all :/
git commit -am 'message'
git push -u origin master


답변

나는 디렉토리 만 추가 한 후 새로운 리포지토리 에서이 일이 일어났습니다.

파일을 추가 한 빨리 (예 : readme), Git Push는 훌륭하게 작동했습니다.

출처:https://stackoverflow.com/questions/4181861/message-src-refspec-master-does-not-match-any-when-pushing-commits-in-git