为什么git remote add不起作用?

时间:2017-08-13 17:08:37

标签: github

为什么在键入git remote add时会看到错误消息?

$ git remote add origin remote repository https://github.com/hashanmalawana/Loginsystem.git
usage: git remote add [<options>] <name> <url>

    -f, --fetch           fetch the remote branches
    --tags                import all tags and associated objects when fetching
                          or do not fetch any tag at all (--no-tags)
    -t, --track <branch>  branch(es) to track
    -m, --master <branch>
                          master branch
    --mirror[=<push|fetch>]
                          set up remote as a mirror to push to or fetch from

1 个答案:

答案 0 :(得分:3)

您应该输入:

git remote add origin https://github.com/hashanmalawana/Loginsystem.git 

不是

git remote add origin remote repository https://github.com/hashanmalawana/Loginsystem.git
                      ^^^^^^^^^^^^^^^^^^

这样,你添加一个名为origin的遥控器,引用远程仓库https://github.com/hashanmalawana/Loginsystem.git

您无法看到使用消息

usage: git remote add [<options>] <name> <url>

我理解&#34; Adding an existing project to GitHub using the command line&#34;的第8步可能令人困惑:

git remote add origin remote repository URL

但最后三个参数实际上只有一个。它应该是:

git remote add origin <remote repository URL>

最好参考actual man page for git remote

git remote add <name> <url>