Franz
Franz

Reputation: 75

Error in Github when I do "git push origin master" (error: src refspec master does not match any)

My branch in the Github repository is "master". In the terminal I did:

git branch

and the output is:

* main

my-temporary-work

I wanted to push a file to Github and I used:

git add exploratory_analysis.ipynb

git commit -m "New version"

git push origin master

The "git add" and "git commit" commands work. However, the last command (i.e., "git push origin master") does not work, and I get this error:

error: src refspec master does not match any

error: failed to push some refs to '[email protected]:NAME-OF-USER/REPOSITORY-NAME.git'

That is, it looks like I cannot push any code from my laptop to Github. How can I fix it?

Upvotes: 0

Views: 3560

Answers (2)

Arslan Ahmad khan
Arslan Ahmad khan

Reputation: 5834

I faced the same issue some days ago. If you created a new repository nowadays(2020) then the default branch in main on GitHub.

you can check on GitHub now in your repository branches.

so that's why you need to run

git push origin main

instead of

git push origin master

Goodluck with more details you can watch video

Upvotes: 3

David S
David S

Reputation: 187

Why are you pushing to master if the branch commands outputs main? Try 'git push origin main'

Also found this explanation for the change: https://stackoverflow.com/a/65008828/1959534

Upvotes: 0

Related Questions