Git push origin master返回"致命:没有指定路径".

use*_*472 19 git github

我最近在github上建立了一个新帐户.我在线跟踪Michael Hartl的Rails教程(http://www.railstutorial.org/book#fig:github_first_page)并按照他的指示设置我的git,它也与github上的设置说明一致.无论如何,github上的"后续步骤"部分是:

  mkdir sample_app
  cd sample_app
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin git@github.com:rosdabos55/sample_app.git
  git push origin master
Run Code Online (Sandbox Code Playgroud)

我一路走到最后一条指令(git push origin master)没有任何问题.但是,当我将最后一行输入到终端时,我收到此错误消息:"致命:未指定路径.请参阅'man git-pull'以获取有效的url语法." 我可能做错了什么?

以下是.git/config的内容(由Jefromi从man git-pull下面粘贴到评论的输出中重建):

[user]
    name = Ross
    email = [REDACTED]
[core]
    editor = gvim -f
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@github.com:
    fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)

Cas*_*bel 23

我在评论中已经说明了另一个答案,但它确实是答案(我已经将评论的相应部分编辑到它所属的问题中).

无论出于何种原因,未正确配置远程URL.它被设置为"git@github.com:",这显然错过了路径,准确地产生了你看到的错误.您需要正确地重新配置它.您可以简单地编辑.git/config,更改相应的行以包含路径.或者你可以这样做:

git remote rm origin
git remote add origin 'git@github.com:rosdabos55/sample_app.git'
Run Code Online (Sandbox Code Playgroud)

当你第一次添加遥控器时,你几乎肯定会犯一些小错误或粗心的错误 - 也许你在它的中间点击输入,也许你在冒号后输入一个空格.(出于某种原因,当你在之后提供额外的参数时,git似乎不会抛出错误remote add <name> <url>- 它只是忽略它.)结果是你实际上没有运行该命令,并且你添加了一个URL不完整的遥控器.