OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

git: error: src refspec main does not match any

  • Thread starter Thread starter naveen
  • Start date Start date
N

naveen

Guest
I was trying to use git via VSCode, and because I didn't know how to use Git on VSCode, it messed up everything.
Then I tried to use CMD (Windows) as usual. I am learning, and I've never seen this kind of error before, so I don't know how to solve this.

But it's showing these errors when I try to push to the main branch:

Code:
error: src refspec main does not match any
error: failed to push some refs to 'myPathToRepo'

I tried:

  • I tried with another branch and it was working fine but I want to use the main branch
  • I even tried deleting the git folder and initiating it again

I've seen other posts on StackOverflow and mostly they say "first commit and then push because this error arises when you're pushing without committing".

After deleting the .git/ folder and restarting, it starts to show this same error

Code:
>git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

>git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'myPathToRepo'

This is my first commit:

Code:
[master (root-commit) 061a06e] first commit

PS. I only have 'main' branch.

Commands that I ran:

Code:
git init
git remote add origin 'pathToMyRepo'
git add -A
git commit -m "first commit"
git push
git push -u origin main

Please help.
<p>I was trying to use git via VSCode, and because I didn't know how to use Git on VSCode, it messed up everything.<br />
Then I tried to use CMD (Windows) as usual. I am learning, and I've never seen this kind of error before, so I don't know how to solve this.</p>
<p>But it's showing these errors when I try to push to the main branch:</p>
<pre><code>error: src refspec main does not match any
error: failed to push some refs to 'myPathToRepo'
</code></pre>
<p>I tried:</p>
<ul>
<li>I tried with another branch and it was working fine but I want to use the main branch</li>
<li>I even tried deleting the git folder and initiating it again</li>
</ul>
<p>I've seen other posts on StackOverflow and mostly they say "first commit and then push because this error arises when you're pushing without committing".</p>
<p>After deleting the <code>.git/</code> folder and restarting, it starts to show this same error</p>
<pre><code>>git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin master

>git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'myPathToRepo'
</code></pre>
<p>This is my first commit:</p>
<pre><code>[master (root-commit) 061a06e] first commit
</code></pre>
<p>PS. I only have 'main' branch.</p>
<p>Commands that I ran:</p>
<pre><code>git init
git remote add origin 'pathToMyRepo'
git add -A
git commit -m "first commit"
git push
git push -u origin main
</code></pre>
<p>Please help.</p>
Continue reading...
 

Latest posts

J
Replies
0
Views
1
jbowerbir
J
V
Replies
0
Views
1
Vinicius Martin
V
Top