阅读(3727) (0)

GitHub 添加远程

2020-08-19 14:42:41 更新

要新增远程,请在终端上存储仓库的目录中使用 git remote add 命令。

git remote add 命令使用两个参数:

  • 远程命令,如 origin
  • 远程 URL,如 https://github.com/user/repo.git

例如:

$ git remote add origin https://github.com/user/repo.git
## Set a new remote


$ git remote -v
## Verify new remote
> origin  https://github.com/user/repo.git (fetch)
> origin  https://github.com/user/repo.git (push)

不确定要使用哪个 URL? 查阅“我应使用哪个远程 URL?

疑难解答

尝试添加远程时可能会遇到这些错误。

远程 name 已存在

此错误消息表示您尝试添加的远程与本地仓库中的远程名称相同:

$ git remote add origin https://github.com/octocat/Spoon-Knife
> fatal: remote origin already exists.

要修复此问题,您可以

延伸阅读