ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[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 ```