我使用以下内容克隆存储库:
git clone ssh://xxxxx/xx.git
但在我更改一些文件并添加和提交它们之后,我想将它们推送到服务器:
git add xxx.php
git commit -m "TEST"
git push origin master
但我得到的错误是:
error: src refspec master does not match any.
error: failed to push some refs to 'ssh://xxxxx.com/project.git'
我想这可能会对某人有所帮助。我今天做出了我的第一次重大承诺。我试了很多指南,但总是出错。
首先:将文件cd到目录中初始化git:gitinit提交文件:gitcommit要在有任何模糊的bash命令时强制提交,请单击I插入提交消息要继续:单击Esc
要发送到GitHub存储库,请首先确保已添加用户名和电子邮件:
git config --global user.name 'Your name'
git config --global user.email 'name@mail.com'
继续:
git remote add origin https://github repo url
要推送到存储库:
git push -u origin 'https://github.repo url'
它将提交加载到存储库中。
完成!!!
我也遇到了同样的问题,并且发现我没有提交任何文件,所以当我再次尝试提交时,我收到了以下错误消息:
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'USER@WINDOWS-HE6I2CL.(none)')
然后我所做的就是在全球范围内添加我的电子邮件和姓名,然后再次提交:
git commit -m 'Initial commit'
然后按下
git push -u origin master
我也遵循了GitHub的指示,如下所示,但我仍然面临着OP提到的同样的错误:
git init
git add .
git commit -m "message"
git remote add origin "github.com/your_repo.git"
git push -u origin master
对我来说,我希望这对一些人有所帮助,我在MacOS上推送了一个大文件(1.58 GB磁盘)。在复制粘贴上面建议的代码行时,我并没有等到处理器真正完成添加。过程因此,当我键入gitcommit-m“message”时,它基本上没有引用任何文件,也没有完成将代码成功提交到GitHub所需的任何操作。
证明这一点的是,当我键入gitstatus时,通常会为添加的文件使用绿色字体。但所有的东西都是红色的,好像根本没有添加。
所以我重新调整了步骤。我键入了gitadd。并等待文件完成添加。然后我完成了接下来的步骤。