我刚开始使用git和github.我按照他们的指示在最后一步遇到了错误.我正在检查当前不受源控制的现有目录(项目大约一周).除此之外,我的用例应该是磨机的运行.
这是发生了什么:
$ 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'
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud) 我在github.com上有一个公共存储库,有2个分支:master和test.
我在本地创建了一个新目录并执行了:
[ ] git clone git@github.com:{username}/{projectname}.git
Run Code Online (Sandbox Code Playgroud)
然后,我创建了一个名为新的分支my_test与
[ ] git branch my_test
Run Code Online (Sandbox Code Playgroud)
并切换到它.
[ ] git checkout my_test
Run Code Online (Sandbox Code Playgroud)
然后我将其与我test的公共存储库的分支 合并
[ ] git merge origin/test
Run Code Online (Sandbox Code Playgroud)
它导致了快速前进.
我做了一些改变并承诺了.然后我尝试将本地my_test分支推送到testgithub上的公共分支
[ ] git push git@github.com:{username}/{projectname}.git test
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误:
error: src refspec test does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git@github.com:{username}/{projectname}.git
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么 ?
将git存储库克隆到目录"hggit"并设置远程源
mbm:hggit my name$ git remote add origin git@code.getpantheon.com:"mystringhere"
Run Code Online (Sandbox Code Playgroud)
编辑文件后,我提交了更改(位于子目录中)
mbm:handelgroup michaelmausler$ git commit -m "first commit"
[master 5a29bc8] first commit
1 files changed, 2 insertions(+), 2 deletions(-)
Run Code Online (Sandbox Code Playgroud)
然后我尝试推送文件更改并收到以下错误
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"'
Run Code Online (Sandbox Code Playgroud)