Fixed: Cannot push after commit

Hi folks,

I am new here and followed these instructions https://docs.github.com/en/free-pro-team@latest/github/working-with-github-pages/creating-a-github-pages-site without success. These are the steps I have taken so far:

  1. Create an account
  2. Used setting tu use the noreply-email
  3. git config --global user.email noreply-email
  4. Generated and registred GPG key for noreply-email
  5. git config --global user.signingkey keyid
  6. Registerd my SSH key
  7. Tested with ssh -T git@github.com
  8. Set command line language to default for english error messages: LANG="C" && export LANG
  9. Created a new repository test1 with a readme.md
  10. Pulled the repository to my Linux machine git clone ssh://git@github.com/ukoehler/test1
  11. cd test1
  12. echo "Hello World" > index.html
  13. git add --all
  14. git commit -m "Initial commit" (Also tried this with signing)
  15. git push -u origin master error: src refspec master does not match any error: failed to push some refs to 'ssh://git@github.com/ukoehler/test1'

All the tips I found where that I forgot to commit locally, but I certainly did. Here is the result of git status:

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

nothing to commit, working tree clean

The output of git remote show origin

git remote show origin
* remote origin
  Fetch URL: ssh://git@github.com/ukoehler/test1
  Push  URL: ssh://git@github.com/ukoehler/test1
  HEAD branch: main
  Remote branch:
    main tracked
  Local branch configured for 'git pull':
    main merges with remote main
  Local ref configured for 'git push':
    main pushes to main (fast-forwardable)

Did I forget something important?

Cheers

Uwe

1 Like

Did you:

git add .

First? Then you will have to commit:

git commit -m "Commit Message"

And then push:

git push origin

The problem is you’re trying to push master while the branch is called main, as the git status output shows.

You might have missed that Github changed the name of the default branch in new repositories to main a while ago. :wink: For details, see:

1 Like

Thanks for yours answer. I did indeed do it in that sequence.

1 Like

Great! Many thanks for your help. Would be good to update the documentation. I would never have expected that is the problem.

2 Likes