🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## 概述 git remote命令管理一组跟踪的存储库 ## 语法 ``` git remote [-v | --verbose] git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url> git remote rename <old> <new> git remote remove <name> git remote set-head <name> (-a | --auto | -d | --delete | <branch>) git remote set-branches [--add] <name> <branch>…​ git remote get-url [--push] [--all] <name> git remote set-url [--push] <name> <newurl> [<oldurl>] git remote set-url --add [--push] <name> <newurl> git remote set-url --delete [--push] <name> <url> git remote [-v | --verbose] show [-n] <name>…​ git remote prune [-n | --dry-run] <name>…​ git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)…​] ``` ## 场景 ### 列出远程分支 ``` $ git remote origin ``` ### 列出分支详情 ``` git remote -v origin http://git.oschina.net/yiibai/sample.git (fetch) origin http://git.oschina.net/yiibai/sample.git (push) ``` ## 添加远程仓库 可以为远程仓库取别名 ``` git remote add pb http://git.oschina.net/yiibai/sample.git ``` ### 添加一个新的远程,并切换新分支 ``` > git remote add staging git://git.kernel.org/.../gregkh/staging.git > git remote origin staging > git fetch staging > git branch -r origin/HEAD -> origin/master origin/master staging/master staging/staging-linus staging/staging-next > git checkout -b staging staging/master ```