I was trying to deploy my source code onto Github.
Then, I first added the github source to remote source as follows:
$ git remote add origin git@github.com:user_name/foo_bar.git*
Then, I tried to run “git push” command to upload my source code onto my remote github account as below.
$ git push
Enter passphrase for key '/c/Users/mylaptop/.ssh/id_rsa':
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 'git@github.com:user_name/foo_bar.git'
As I learned from railstutorial.org, I know if I use “git push” for the first time, it will return an error expecting me to specify ‘origin master’ parameters. But for the next and later times, I can only fire up “git push”, it will work gracefully for me. What is the reason for that? as I thought the command by default always refers to the branch ‘master’.
Any clear explanation would be really appreciated.
The first time you do
git push, there is no remote branch called master on origin.After the branch exists, you can use
git pushand it will link to the remote branch with the same name of the branch you are currently on.