I clone my repository with:
git clone ssh://xxxxx/xx.git
But after I change some files and add
and commit
them,
I faced the same problem, and I used --allow-empty
:
$ git commit -m "initial commit" --allow-empty
...
$ git push
...
One of main reasons of this problem is that some Git servers, such as BitBucket, don't have their master
branch initialized when a fresh repository is cloned.
Short answer: This error means the branch you want to push in remote doesn't exist!
In my case, starting from October-2020, the repos created since then had the main
branch instead of the previous master
branch. So all I had to do this:
git push -u origin main
Bingo! That worked for me! Hope that helps! Happy coding!
So I tried Vi's solution:
git push origin HEAD:<remoteBranch>
This worked for me.
To check the current status, git status
.
And follow these steps as well:
git init
git add .
git commit -m "message"
git remote add origin "github.com/your_repo.git"
git push -u origin master
I had the same problem when I missed to run:
git add .
(You must have at least one file, or you will get the error again.)
I had the same problem. I did it by the following steps:
1. git commit -m 'message'
2. git config --global user.email "your mail"
3. git config --global user.name "name"
4. git commit -m 'message'
5. git push -u origin master