0

I am trying to push my index.html project to my GitHub. I created my repo but, when I run the following commands on my terminal:

PS C:\Users\pc\Documents\Sites\kodluyoruz-frontend> git remote origin
PS C:\Users\pc\Documents\Sites\kodluyoruz-frontend> git push -u origin main

I am getting this error:

error: src refspec main does not match any
error: failed to push some refs to 'https://https://github.com/alpino87/-lk-Html-Sayfam'
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
  • Does this answer your question? [Git: Message 'src refspec master does not match any' when pushing commits in Git](https://stackoverflow.com/questions/4181861/git-message-src-refspec-master-does-not-match-any-when-pushing-commits-in-git) – Gino Mempin Oct 01 '21 at 04:49

2 Answers2

0

This error message can occur in git if your remote repo does not exist. Double-check the name of your GitHub repository URL and then run the following command:

git remote set-url origin <new-url>

Then you can try your git push -u origin main command again and it should work

Daniel Arthur
  • 456
  • 7
  • 17
  • Thank you, but then I got this error =)))) error: No such remote 'origin' PS C:\Users\pc\Documents\Sites\kodluyoruz-frontend> – Alpino87 Sep 23 '21 at 16:24
0

Some observations:

  • The remote url mentioned in your first error is https://https://github.com/alpino87/-lk-Html-Sayfam. That is incorrect. Not only is there a double https://. The username mentioned also does not exist on github.
  • Your second error in the comments of @daniel-arthur indicates that the remote is missing entirely.
  • The refspec main does not match could indicate that you have not yet committed your files. If so, add some files git add . and commit them git commit -m 'some message' before pushing.

Debugging:

I would follow the following steps to debug your issue:

  1. Check what branches you have locally and thus can push via git branch. Based on your example, you should have a main branch.
  2. See if you have a valid remote called origin: git remote -v

Possible causes of error:

  1. You don't have a branch called main. To fix this, create this branch from your currently checked out branch via git checkout -b main.
  2. You don't have a remote called origin. To fix this, create a new remote via git remote add origin <url of origin remote>
  3. You have a remote called origin, but it is wrong. To fix this, you can remove the old origin and re-add the correct one as described at (2). To remove: git remote rm origin.

After above fixes, you should be good to push your main branch to your remote called origin via git push -u origin main.

For reference, see: https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories

Eelke van den Bos
  • 1,423
  • 1
  • 13
  • 18