[Git] 初回の git push でエラーが出る場合の対処法

commitを行いまっさらなリポジトリに意気揚々とgit pushをかけようとすると、以下のようなエラーが出る場合があります。

fatal: The remote end hung up unexpectedly

$ git push
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'ssh://git.example.org:50022/reposgit/endymion.git'

git push origin master

このエラーは一体どこにファイルをアップすればいいの?という意図になりますので、「git push」のあとに当該部分を指定してやれば解決します。

$ git push origin master
Counting objects: 190, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (186/186), done.
Writing objects: 100% (190/190), 270.51 KiB, done.
Total 190 (delta 34), reused 0 (delta 0)
To ssh://git.example.org:50022/reposgit/endymion.git
* [new branch]      master -> master

originは接続先のサーバの略称、 masterはデフォルトのブランチ名にあたります。

2回目以降はgitがいい感じに処理してくれますので、必要がなければ指定しなくて大丈夫です。

$ git push
Everything up-to-date

参考