bash:意外标记“'git config --global user.name "firstname lastname"'”附近的语法错误

bash: syntax error near unexpected token `'git config --global user.name "firstname lastname"''

我正在尝试设置我的 SSH 密钥,以便我可以将我的程序代码从 RStudio 推送到我创建的 GitLab 存储库。

运行 在我的 RStudio 终端中执行以下命令

$ system('git config --global user.name "firstname lastname"')

returns 出现以下错误:

bash: syntax error near unexpected token 'git config --global user.name "firstname lastname"''

所以我猜 RStudio 不喜欢引号,但我已经尝试了双引号和单引号的所有组合,我仍然得到 bash: syntax error.

知道我做错了什么吗?

您正在与 Bash shell 对话,它需要 shell 命令,如 git,而不是 R repl,需要 R 表达式,如 system(..)。删除 system(..) 并直接 运行 命令:

$ git config --global user.name "firstname lastname"