可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
This question already has an answer here:
After cloning git repository to directory "hggit" and setting the remote origin with
mbm:hggit my name$ git remote add origin git@code.getpantheon.com:"mystringhere"
After editing files I committed the changes (while located in a sub-dir) with
mbm:handelgroup michaelmausler$ git commit -m "first commit" [master 5a29bc8] first commit 1 files changed, 2 insertions(+), 2 deletions(-)
I then attempted to push file changes and received the following error
mbm:hggit myname$ git push origin master error: src refspec master does not match any. error: failed to push some refs to 'git@code.getpantheon.com:"mystringhere"'
回答1:
If git status
does indicate that you do have an active master branch (since you did make a first commit after all), check if you made any typo when defining your remote: see "Push origin master error on new repository":
git remote rm origin
Then I recreated the origin, making sure the name of my origin was typed EXACTLY the same way my origin was spelled.
git remote add origin git@....
You can simplify with:
git remote set-url origin git@....
Then you can establish a tracking link between the local branch and the remote tracking branch:
git push -u origin master
You can also push it to a different branch on origin:
git push -u origin master:anotherBranch
回答2:
use git branch -m to rename your local repository to have the same name you want to push to the remote
回答3:
You need to make sure that the branch name is the same locally and remotely. So it's not enough to have master
branch on remote. You also need this branch locally.
回答4:
Maybe your file have "\r" character