Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialHanxiao Jiang
8,526 PointsFailed to push to GitHub.
it says:
error: src refspec master does not match any. error: failed to push some refs to 'https://...'
Really appreciate it if anyone could help.
2 Answers
Steve Hunter
57,712 PointsOK - when you did your first push, did you define the relationship between origin
and master
?
Something like, git push -u origin master
Steve.
Steve Hunter
57,712 PointsHi there,
If you type git remote
and git remote -v
, what do you get?
Steve.
Hanxiao Jiang
8,526 Pointshi, thx for replying.
I got after git remote -v
origin https://github.com/username/myrep.git (fetch)
origin https://github.com/username/myrep.git (push)
Besides, how did you change the font of "git remote -v" using markdown? Thanks.
Steve Hunter
57,712 PointsOdd. Something's wrong with master
what does git branch -v
give you?
Steve Hunter
57,712 PointsI suspect either the repo isn't initialized or no initial commit has been made?
Hanxiao Jiang
8,526 Pointsafter branch
* master 7f7bca2 first commit
Hanxiao Jiang
8,526 PointsHanxiao Jiang
8,526 PointsYes, I did. And after that, errors appears like in the original question.
error: src refspec master does not match any. error: failed to push some refs to 'https://...'
As I started this in my local git bash rather than treehouse workspace where I already have rep and branches, maybe I did not create a branch, change my username or something
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsRight - what are you trying to commit? Local code or a workspace? If there's an inconsistency there, you'll throw the error that you've got. Yes, Git errors are the least helpful errors ever (until you get into Android!).
If you are trying to push a workspace to Github you need to run your commands in the repl/workspace (I've never tried that, to be honest). If you're pushing local code, you seem to have done everything correctly. I'd be interested to see the remote repo to see what's going on there.
Look me up on Github here alwys good to have followers!
Hanxiao Jiang
8,526 PointsHanxiao Jiang
8,526 PointsThank you for your time and help.
I had previous code on workspaces and then create a new repository locally. Something might be missing locally. I'll try to start from scratch to see if it works tomorrow. It's quite late in Sydney.
Again, really appreciate your help. Have a nice day :)
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsGive me a shout when you've had chance to look at it - if you're still struggling, we can revisit what you're trying to do.
Steve.