Error: refname refs/heads/master not found #24104
-
Hi I am trying to publish my third site, so I fairly new to github, and I am getting: the following error:
I have used git-bash, them some code on github account, and on the above stage I got the error. |
Beta Was this translation helpful? Give feedback.
Replies: 21 comments 7 replies
-
Did you solve the problem ? I take that error too and couldn’t find solution |
Beta Was this translation helpful? Give feedback.
-
Could the branch possibly be named |
Beta Was this translation helpful? Give feedback.
-
Can I post the link to the solution here? Its an external source… and its in Portuguese: Basically what I did was to run the
them |
Beta Was this translation helpful? Give feedback.
-
I had this error as well, but it cleared after I made my initial commit. That might be the issue? |
Beta Was this translation helpful? Give feedback.
-
I deleted the repo, and started all over again, and it come right. thanks 😀 |
Beta Was this translation helpful? Give feedback.
-
same here, it turns out that to make a first push you gotta make a first commit first |
Beta Was this translation helpful? Give feedback.
-
I also deleted the repo and it worked! |
Beta Was this translation helpful? Give feedback.
-
A branch is a pointer to a commit, so if no commit has been created yet, then no branch exists. So you cannot rename a branch which does not exist. The solution is to do a first commit, which will create a branch (master by default), and then you should be able to rename it (now that it exists). So in other words:
|
Beta Was this translation helpful? Give feedback.
-
Run git config --global user.email “you@example.com” and then make your first commit. $ git commit -m “first commit” and now run the command $ git branch -M main It worked for me this way. |
Beta Was this translation helpful? Give feedback.
-
Yeah, this here is the simpler solution. |
Beta Was this translation helpful? Give feedback.
-
git init That worked for me/ |
Beta Was this translation helpful? Give feedback.
-
For me, the problem was that I had untracked files. Once you “git add …” + “git commit …”, you can rename the branch. |
Beta Was this translation helpful? Give feedback.
-
that was why! thanks! |
Beta Was this translation helpful? Give feedback.
-
Change branch name from master to mainBy google-ing, we'd find a simple command as git branch -m master main which should rename the maste... |
Beta Was this translation helpful? Give feedback.
-
You are currently in detached head state. You must checkout a new branch to associate it with the current commit: |
Beta Was this translation helpful? Give feedback.
-
yea it worked for me |
Beta Was this translation helpful? Give feedback.
-
Thanks. I had the same issue. Did the first commit. pushed to remote origin first time fine. Thanks again for the tip |
Beta Was this translation helpful? Give feedback.
-
It helped me, I needed to make a commit first and after run git branch -M master |
Beta Was this translation helpful? Give feedback.
-
i just had to register so i can say this, you saved me a whole lot of stress with this comment… i was using master in my header and i have been stuck at it for hours just for me to stumble upon this comment and i changed “master” to “main” and boom, it worked thank you buddy… |
Beta Was this translation helpful? Give feedback.
-
If none of the above worked for you, your issue may be the following: You have a local branch (say Unfortunately this creates a deferred issue for you. As soon as you do a push or pull on
The solution is simple:
If this helps you, please upvote so others see this closer to the top, because none of the above solutions will work for this relatively common case that confounds people. |
Beta Was this translation helpful? Give feedback.
-
In my case, I was trying to create the branch in "an existing repository", but this was not existing, so it followed the github rules, and I had to create a new repository from my project's parent directory.
|
Beta Was this translation helpful? Give feedback.
Can I post the link to the solution here? Its an external source… and its in Portuguese:
https://pt.stackoverflow.com/questions/388005/problema-na-hora-de-fazer-push-no-github
Basically what I did was to run the
them
git push