Failed to push some refs when using push


I create a repository in Github and on my local machine I ran the code:

git init
git branch -m main
git remote add origin
git push -u origin main

Instead of using master branch I want to use main branch.

When running git push -u origin main I get the error:

failed to push some refs to ''

What am I doing wrong?


Is your local repo empty?

In this case, you need to add a file and commit it.

1. Run notepad test.txt (Windows) or touch test.txt (Mac)
2. Save the file.
3. git add . 
4. git commit -m "Initial commit"
5. git push -u origin main

Answered By – Christian

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published