git remote 命令

本文介绍了git remote 命令使用,git remote命令用于在远程仓库执行操作.

git remote 命令

git remote 命令用于在远程仓库的操作。

显示所有远程仓库:

git remote -v

以下我们先载入远程仓库,然后查看信息:

$ git clone https://github.com/test/aa
$ cd aa
$ git remote -v
origin  https://github.com/test/aa (fetch)
origin  https://github.com/test/aa (push)
origin 为远程地址的别名。

显示某个远程仓库的信息:

git remote show [remote]

例如:

$ git remote show https://github.com/test/aa
* remote https://github.com/test/aa
  Fetch URL: https://github.com/test/aa
  Push  URL: https://github.com/test/aa
  HEAD branch: master
  Local ref configured for 'git push':
    master pushes to master (local out of date)

添加远程版本库:

git remote add [shortname] [url]

shortname 为本地的版本库,例如:

# 提交到 Github
$ git remote add origin git@github.com:test/aa.git
$ git push -u origin master

其他相关命令:

git remote rm name  # 删除远程仓库
git remote rename old_name new_name  # 修改仓库名
上一篇 下一篇


推荐文章

评论
说点什么吧?

发表评论

取消回复
  最新文章