0

I am having trouble pushing updates from my local repository to my GitHub master.

I have cloned a test repository that I initially created on GitHub, have made a few small updates, and am now trying to push these updates back to the master.

After adding the files, I am getting errors for both commit and push which appear to be circular and I'm unclear on how to resolve.

I have added the updates from my local repository using:

git add .

When I try to commit I get the following message:

git commit -m "Test update of Index.html"`

On branch main
Your branch is ahead of 'origin/main' by 1 commit.
  (use "git push" to publish your local commits)`

When I then try to push the updates I get the following error:

git push origin master  

error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/Username/HelloWorld.git' `

The troubleshooting advice I can find for this error all say to first commit my updates, which I am unable to do.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Ollie
  • 11
  • 4
  • 3
    `git push origin master` - but you're on `main`... In general, you should just be able to `git push`, specifying the remote and branch is only necessary when you're not doing the default thing of pushing to the remote named `origin` and the branch matching your local one. – jonrsharpe Dec 30 '22 at 12:35
  • Please read: https://www.biteinteractive.com/of-git-and-github-master-and-main/ – matt Dec 30 '22 at 14:29

1 Answers1

1

Your git add and git commit calls seem to be successful. Your git push origin master call fails because there's not branch master in the remote repository. Since your local branch is main, I'm guessing you meant to push to the remote branch of the same name. You could use git push origin main, or even just git push, and rely on the defaults.

Mureinik
  • 297,002
  • 52
  • 306
  • 350