I was contributing to one GitHub repository, so I forked the project, cloned it, created my own branch, did some commits, and tried to push.
At this point I discovered that I cloned not my fork, but the original project repository (which I don't have permission to push to).
So I changed the .git/config
to point origin
to my repository.
At this point, when I tried to push, I was getting the error error: src refspec my_awesome_branch does not match any.
All I had to do was to touch any file and commit it (similar like you see it in this answer):
git touch README
git commit -m "fixing error in my git repo"
And then:
git checkout master
git pull origin master
git push origin master # This will tell my remote repository about my new branch
git checkout my_awesome_branch
git push origin my_awesome_branch # Now it will work
git status
to get the proper one. – Groffgit commit
can cause this error, as well! – Besprinklegit add
with dot or some files this error also will appear. – Recruitmentgit branch -M main
and it will work – Masbategit pull origin main
, after that I could push my changes. I believe this overwrites your branch though – Determinate