最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】git中push origin master出错:error: src refspec master does not match any.

Git crifan 15898浏览 0评论

【问题】

git中向服务器提交文件时出错:

Administrator@NYBDHB7EB3XEHP6 /cygdrive/e/Dev_Root/freelance/Elance/projects/Node.js/git_root/uyb-dev
$ ls
server.js

Administrator@NYBDHB7EB3XEHP6 /cygdrive/e/Dev_Root/freelance/Elance/projects/Node.js/git_root/uyb-dev
$ git push origin master
Password for 'https://[email protected]':
error: src refspec master does not match any.
error: failed to push some refs to 'https://[email protected]/uyb-dev.git'

【解决过程】

1.参考:

学习git (一)

得知是由于当前项目下没有文件供上传,项目为空所导致的。

但是我这里明显是有一个文件的。

2.后 参考:

CentOS下搭建Git服务器Gitosis[教程]

得知,先去add,再commit,然后再push,就可以了:

Administrator@NYBDHB7EB3XEHP6 /cygdrive/e/Dev_Root/freelance/Elance/projects/Node.js/git_root/uyb-dev
$ git push android master
Password for 'https://[email protected]':
error: src refspec master does not match any.
error: failed to push some refs to 'https://[email protected]/uyb-dev.git'

Administrator@NYBDHB7EB3XEHP6 /cygdrive/e/Dev_Root/freelance/Elance/projects/Node.js/git_root/uyb-dev
$ git add server.js

Administrator@NYBDHB7EB3XEHP6 /cygdrive/e/Dev_Root/freelance/Elance/projects/Node.js/git_root/uyb-dev
$ git commit server.js
error: cannot run vi: No such file or directory
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

Administrator@NYBDHB7EB3XEHP6 /cygdrive/e/Dev_Root/freelance/Elance/projects/Node.js/git_root/uyb-dev
$ git commit -a -m server.js
[master (root-commit) e119893] server.js
 Committer: U-NYBDHB7EB3XEHP6\Administrator <Administrator@NYBDHB7EB3XEHP6.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email [email protected]

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 files changed, 6 insertions(+), 0 deletions(-)
 create mode 100755 server.js

Administrator@NYBDHB7EB3XEHP6 /cygdrive/e/Dev_Root/freelance/Elance/projects/Node.js/git_root/uyb-dev
$ git push android master
Password for 'https://[email protected]':
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 412 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: New deployment received.
remote: Updating branch 'master'.
remote: Preparing deployment for commit id 'e119893a59'.
remote: Preparing files for deployment.
remote: Deploying Web.config to enable Node.js activation.
remote: Selecting nodejs version.
remote: The package.json file is not present.
remote: The node.js application will run with the default node.js version 0.6.20.
remote: Deployment successful.
To https://[email protected]/uyb-dev.git
 * [new branch]      master -> master

 

【总结】

不是当前文件夹下没有文件,而是没有把文件添加到git项目中,

通过先add文件再commit 文件到项目中,然后就可以把项目中的文件,push到服务器上了。

转载请注明:在路上 » 【已解决】git中push origin master出错:error: src refspec master does not match any.

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (2)

  1. 还有一种情况, 就是推错了分支, git push origin master 和 git push origin develop
    shine10年前 (2015-04-25)回复
86 queries in 0.184 seconds, using 22.12MB memory