You are on a branch yet to be born
Im have strange problem:
$ cd ~/htdocs
$ mkdir test
$ cd test
$ git init
Initialized empty Git repository in /home/deep/htdocs/test/.git/
$ git checkout master
error: pathspec 'master' did not match any file(s) known to git.
$ git checkout -b master
fatal: You are on a branch yet to be born
$ git checkout origin/master
error: pathspec 'origin/master' did not match any file(s) known to git.
$ git branch -a
(empty this)
But this is new local empty repo. Where is master branch?
As ever, Git is right, it just has a quirky way of saying it: when you create a repository, the master branch actually doesn't exist yet because there's nothing for it to point to.
Have you tried committing something after your git init
? Adding a remote and pulling from it will also work, of course.
I had the same problem as you. The way I solved was creating a new empty file just to have a file in the project.
git add someFile
then commit -m "first commit"
and finally with push origin master
i hope it helps
If someone reaches this part, I think you have no luck with the top answers. I got the same situation with OP too. Try this:
- Pull your repo in another directory
- copy .git folder to your new repo