Search code examples
gitgithubgithub-for-mac

Error while pushing code to github public drive


I am new to github and trying to create my first repository. After executing the below command:

$ git push -u origin master

I am getting following error:

error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/rs/python-gtts.git

Few things I did,

Created a folder in my local: /Users/TrainingLearning/github/Python

After that executed following command:

echo "# python-gtts" >> README.md
git init
git add README.md

Then added my code (Python file - TextToSpeech.py) to the same folder where I earlier created README.md file: /Users/TrainingLearning/github/Python

And tried doing:

$ git add .
$ git commit -m "first commit"
$ git remote add origin https://github.com/rs/python-gtts.git

But when I execute following command:

$ git push -u origin master

I started getting following error:

error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/rs/python-gtts.git'

Solution

  • I found the problem, my git was not properly configured, so I had to run following commands:

    $ git config --global user.email "[email protected]" $ git config --global user.name "xxxx"

    After this I was successfully able to push my code into git by running following commands:

    $ git commit -m "Initial Commit" $ git push -u origin master