Home > OS >  src refspec main does not match any: failed to push some refs to git (for existing project)
src refspec main does not match any: failed to push some refs to git (for existing project)

Time:12-08

I need to upload an existing project to my own repository

Preconditions:

  • I have downloaded a new project from a zip file
  • I have created a new project on my own git repo

Steps:

I have followed the given instruction from the git:

git init git remote add origin https://... git branch -M main git push -uf origin main

Error:

error: src refspec main does not match any error: failed to push some refs to 'https://gitlab.com/../...-main.git'

Additional info:

  • I have established the ssh connection with my repository and successfully have used git on the other projects.

  • I also have tried the option with git remote add origin [email protected]:..../...-main.git but received the same result


How to resolve this issue?

CodePudding user response:

double-check you have the remote added with

git remote -v 

you should see your remote repository url, then try

git fetch origin main

instead of pushing.

you can push once do the fetching.

  • Related