I am trying to add a file to my repository on BitBucket and I am having trouble.
I am using GIT and this is what I type in
$ cd lis4368/assignments $ git remote $ git remote -v $ git remote rm origin
and then I type this in (this is what BitBucket tells me to enter)
$ git remote add origin https://[email protected]/cpb09e/cpb09e.git $ git push -u origin master
And I keep getting this error message:
error: src refspec master does not match any. error: failed to push some refs to 'https://[email protected]/cpb09e/cpb09e.git'
Can someone pleas help me out? I have tried everything from git commit to rm -rf * and I cannot get anything to work at all.
The solution to this error is to either create a local and remote master branch that you can push the commit to or to push the commit to an existing branch – maybe main . These commands will create a master branch locally. And by pushing to origin master , the master branch will also be created remotely.
The most probable reason for this error is that all the files are untracked and have not been added. git add --all in case you wish to add all the files Or you can selectively add files. Then git commit -m "Initial comment" , git push origin master . This will surely work.
Whenever we need to push the changes to a remote repository, we use git push along with the remote repository “origin” and “master” branches. The term used is “git push origin master“. To pull the changes from the remote repository to local, we use git pull along with remote repository “origin” and “master” branch.
The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.
One classic root cause for this message is:
git init lis4368/assignments
),Ie, if you don't have added and committed at least once, there won't be a local master
branch to push to.
Try first to create a commit:
git add .
) then git commit -m "first commit"
git commit --allow-empty -m "Initial empty commit"
And then try git push -u origin master
again.
See "Why do I need to explicitly push a new branch?" for more.
It doesn't recognize that you have a master branch, but I found a way to get around it. I found out that there's nothing special about a master branch, you can just create another branch and call it master branch and that's what I did.
To create a master branch:
git checkout -b master
And you can work off of that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With