• 查看当前的远程仓库 命令: -v 选项显示对应的克隆地址

    1
    
    git remote

    例子:

    1
    2
    
    git remote
    git remote -v
  • 添加到远程仓库

命令:

1
git remote add [shortname] [url]
1
   例子:
1
git remote add pb git://github.com/binbean/ticgit.git
  • 推送数据到远程仓库 命令:

    1
    
    git push [remote-name] [branch-name]
    1
    
    例子:把本地的master分支推送到origin服务器上(克隆操作会自动使用默认的master和origin名字)
    1
    
    git push origin master
  • 查看远程仓库信息 命令:

    1
    
    git remote show [remote-name]
    1
    
    例子:查看所克隆的origin仓库
    1
    
    git remote show origin
  • 远程仓库删除和重命名 命令:

    1
    2
    
    git remote rename name-from name-to    #重命名
    git remote rm paul                     #删除
    1
    
    例子:

    1.把pb改成paul(原来的pb/master分支现在成了paul/master)

    1
    
    git remote raname pb paul

2.删除paul仓库

1
git remote rm paul
  • 从远程仓库抓取数据 此命令会到远程仓库中拉取所有你本地仓库中还没有的数据。 如果是克隆了一个仓库,此命令会自动将远程仓库归于 origin 名下。所以,git fetch origin 会抓取从你上 次克隆以来别人上传到此远程仓库中的所有更新(或是上次 fetch 以来别人提交的更新)。有一点很重要, 需要记住,fetch 命令只是将远端的数据拉到本地仓库,并不自动合并到当前工作分支,只有当你确实准备好 了,才能手工合并。 命令:

    1
    
    git fetch [remote-name]