Stacked trying to push a repository to github

When I try to push my local repositori to Github doing this:

git remote add origin https://github.com/Radu-A/colmar.git
git branch -M main
git push -u origin main

I always get this error message:

$ git branch -M main
error: refname refs/heads/main not found
fatal: Branch rename failed

I tried changing “main” for “master”, nothing happends.

What are your current available branch names? Just typing git branch should list them. Using -M with one argument is just a quick way of renaming your current branch (forced version, will overwrite another branch with that name) but it almost seems like there isn no current branch. Have you made any commits or removed branches?

1 Like

First of all, thanks a lot.

Well, actually I didn’t know. It isn’t well explained in the tutorials I saw. After doing what you explained me (thanks!), I figured out I have only “Main”.

Just like that. I made the first commit of the repository and I could push it to github.

:sweat_smile:

1 Like