【发布时间】:2010-10-24 01:31:38
【问题描述】:
我刚开始在 github 上使用 git。我按照他们的指示在最后一步遇到了错误。我正在检查当前不受源代码控制的现有目录(大约一周前的项目)。除此之外,我的用例应该很正常。
这是发生了什么:
$ git push origin master
error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git@github.com:{username}/{projectname}.git'
Github 使用说明:
Global setup:
Download and install Git
git config --global user.name "Your Name"
git config --global user.email {username}@gmail.com
Next steps:
mkdir projectname
cd projectname
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:{username}/{projectname}.git
git push origin master
【问题讨论】:
-
看来初始提交无论出于何种原因都不起作用。 Git 日志帮助我查看提交是否有效。第二天我又试了一次,成功了。谢谢!
-
如果你不添加任何文件、提交或运行 git init,你总是会遇到这类问题。因此,请始终运行
git status以查看是否一切正常。 -
从现有代码创建分支到新创建的 git 存储库时出现类似错误。通过克隆 git 存储库解决了错误。
-
Error when “git push” to github 的可能重复项。