Solving Ref-Spec Error
Notice: This worked for me but your problem may have a different solution.
For some reason when I made some changes to my Octopress blog and git added, git committed, and git pushed to my origin/master branch I got this error:
At first I tried
git push -u origin master or
git push origin master -f to try and force a push to the ‘origin/master’ branch but I was matched with the same error. After looking at Stack Overflow questions like error: src refspec master does not match any I attempted some of the solutions. First I used
git push origin HEAD:master which worked perfectly but I felt that was a cheap solution and wanted the answer not a cop-out.
I then tried
git branch -mv origin master which told me the origin ref was missing which I thought very strange since I could push to the “origin/master” branch. Let me check the git branches, voilà, there was no master branch. Now, I don’t know how or why my master branch disappeared but that’s for another day.
I re-intialized the git repository for good measure and created a branch called ‘master’. No erroneous alerts so I must be doing something right. When I checked the git branches again, there it was. So, I checked out into master and did my business. I think I held my breath when I entered
git push origin master.
Step 0. Re-initialize the git repo
git branch master and
git checkout master
Step 2. ???
Step 3. Profit
Keep on being badass programmers!