remote

最后更新于:2022-04-02 02:53:28

[TOC] ## 概述 git remote命令管理一组跟踪的存储库 ## 语法 ``` git remote [-v | --verbose] git remote add [-t ] [-m ] [-f] [--[no-]tags] [--mirror=] git remote rename git remote remove git remote set-head (-a | --auto | -d | --delete | ) git remote set-branches [--add] …​ git remote get-url [--push] [--all] git remote set-url [--push] [] git remote set-url --add [--push] git remote set-url --delete [--push] git remote [-v | --verbose] show [-n] …​ git remote prune [-n | --dry-run] …​ git remote [-v | --verbose] update [-p | --prune] [( | )…​] ``` ## 场景 ### 列出远程分支 ``` $ 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 ```
';