Komunikat 'src refspec master does not match any' podczas przesuwania commitów w Git

Sklonowałem moje repozytorium za pomocą:

git clone ssh://xxxxx/xx.git 

Ale po tym jak zmienię niektóre pliki i add i commit je, chcę je wypchnąć na serwer:

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

Ale błąd, który dostaję z powrotem to:

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

Może po prostu musisz się zaangażować. Wpadłem na to, kiedy to zrobiłem:

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

Ups! Nigdy nie popełnione!

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

Wszystko co musiałem zrobić to:

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

Sukces!

Komentarze (19)
  1. Spróbuj git show-ref aby zobaczyć jakie masz refy. Czy jest tam refs/heads/master?

  2. Możesz spróbować git push origin HEAD:master jako bardziej niezależne od lokalnych refów rozwiązanie. To wyraźnie określa, że chcesz popchnąć lokalny ref HEAD do zdalnego ref master (zobacz dokumentację git-push refspec).

Komentarze (17)

Odkryłem, że stało się to w zupełnie nowym repozytorium po tym, jak git dodałem tylko katalog.

Jak tylko dodałem plik (np. README), git push działał świetnie.

Komentarze (5)