Whenever i execute the command git push -u origin main i get the response from the terminal error: src refspec main does not match any
error: failed to push some refs to ‘https://github.com/Po etc etc,
does anyone know a solution?
I tried to relink the remote origin which the terminal tells me exists, ive ran git status which shows me all the currently staged files waiting to be committed. From there i ran git commit and then ran git push -u origin main which worked but im confused why it didnt work beforehand?
2
Answers
See this reasons of your error
Your stage area need to be cleared before pushing to remote repository, and that is why you need to commit before pushing.
This is what I found searching on Internet:
It could be that the main branch didn’t exist yet in the online repository, so that’s why you received that error message. By committing your changes prior to pushing, you were able to create the main branch in the online repository and then push it. Another possibility is that there was a mistake in the branch name or some kind of permissions problem which prevented you from pushing your changes. If the issue continues, you can attempt to remove both the local and remote main branches and create them again. If that doesn’t work, you can always reach out to GitHub support for assistance.