美文网首页Git
「简单Git」remote

「简单Git」remote

作者: 吴小傲 | 来源:发表于2018-02-07 23:09 被阅读10次
2018-02-07 创建文章

概要

命令管理一组跟踪的存储库。

git remote

列出已经存在的远程仓库。

bogon:SimpleGit wuao$ git remote
origin

git remote -v

列出详细信息,在每一个名字后面列出其远程 url。

bogon:SimpleGit wuao$ git remote -v
origin  https://gitee.com/CoderWuao/SimpleGit.git (fetch)
origin  https://gitee.com/CoderWuao/SimpleGit.git (push)

git remote add repository url

添加远程仓库。

  • 当前状态
bogon:SimpleGit wuao$ git remote
origin
bogon:SimpleGit wuao$ git branch -r
  origin/HEAD -> origin/master
  origin/master
  • 添加远程仓库并且查看当前状态
bogon:SimpleGit wuao$ git remote add staging https://gitee.com/CoderWuao/SimpleStaging.git
bogon:SimpleGit wuao$ git remote
origin
staging
bogon:SimpleGit wuao$ git branch -r
  origin/HEAD -> origin/master
  origin/master
bogon:SimpleGit wuao$ git fetch staging
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://gitee.com/CoderWuao/SimpleStaging
 * [new branch]      master     -> staging/master
bogon:SimpleGit wuao$ git branch -r
  origin/HEAD -> origin/master
  origin/master
  staging/master

git remote rename oldRepository newRepository

修改远程仓库名。

  • 当前状态
wuaodeMacBook-Pro:SimpleGit wuao$ git remote
origin
staging
  • 重命名
wuaodeMacBook-Pro:SimpleGit wuao$ git remote rename staging newStaging
wuaodeMacBook-Pro:SimpleGit wuao$ git remote
newStaging
origin

git remote rm repository

删除远程仓库。

  • 当前状态
wuaodeMacBook-Pro:SimpleGit wuao$ git remote
origin
staging
wuaodeMacBook-Pro:SimpleGit wuao$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/staging/master
  • 删除远程仓库
wuaodeMacBook-Pro:SimpleGit wuao$ git remote rm staging
wuaodeMacBook-Pro:SimpleGit wuao$ git remote
origin
wuaodeMacBook-Pro:SimpleGit wuao$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

git remote show repository

可以查看该主机的详细信息。

  • 当前状态
wuaodeMacBook-Pro:SimpleGit wuao$ git branch -a
  master
* stagingMaster
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/staging/master
wuaodeMacBook-Pro:SimpleGit wuao$ git branch -vv
  master        43f3633 [origin/master] first commit
* stagingMaster 9a25682 [staging/master] Initial commit
  • 查看主机信息
wuaodeMacBook-Pro:SimpleGit wuao$ git remote show origin
* remote origin
  Fetch URL: https://gitee.com/CoderWuao/SimpleGit.git
  Push  URL: https://gitee.com/CoderWuao/SimpleGit.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)
wuaodeMacBook-Pro:SimpleGit wuao$ git remote show staging
* remote staging
  Fetch URL: https://gitee.com/CoderWuao/SimpleStaging.git
  Push  URL: https://gitee.com/CoderWuao/SimpleStaging.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    stagingMaster merges with remote master
  Local ref configured for 'git push':
    master pushes to master (local out of date)

查看更多「简单Git」

相关文章

网友评论

    本文标题:「简单Git」remote

    本文链接:https://www.haomeiwen.com/subject/puhhgxtx.html