How to fetch all Git branches
问题描述
I cloned a Git repository, which contains about five branches. However, when I do git branch I only see one of them:
$ git branch
- master
I know that I can do git branch -a to see all the branches, but how would I pull all the branches locally so when I do git branch, it shows the following?
$ git branch
- master
- staging
- etc...
问题来源
https://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches/19644021
这个问题是在stackoverflow上的,本来想完善一下回答,无奈登录失败,那就把终极答案放在这里。
终极答案
To avoid the error message 'fatal: A branch named 'origin/master' already exists.'
, you need this:
git branch -r | grep -v '\->' | grep -v `git branch | awk '/\*/ { print $2; }'`| while read remote; do git branch --track "${remote#origin/}" "$remote"; done
How to fetch all Git branches的更多相关文章
- usage: git remote add [<options>] <name> <url> -f, --fetch fetch the remote branches --tags import all tags and associated objects when fetching
按照git官网提示输入 git pushgit remote add origin git@github.com:***3 / elm-1.git -u 链接git远程仓库 出现错误 usage: g ...
- git fetch和git pull对比
情景重现 你:面试官您好,我是xxx,毕业于xxx学校,工作xxx年,精通各种git命令. 面试官:您好您好,我问个常见的问题考察一下您的技术水平哈.请问,git pull和git fetch有什么区 ...
- Git fetch和git pull的区别
Git中从远程的分支获取最新的版本到本地有这样2个命令:1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge git fetch origin mastergit log - ...
- git fetch和git pull(转载)
From:http://www.tech126.com/git-fetch-pull/ Git中从远程的分支获取最新的版本到本地有这样2个命令: 1. git fetch:相当于是从远程获取最新版本到 ...
- git fetch和git pull之间的区别--转载
原文地址:http://blog.csdn.net/a19881029/article/details/42245955 git fetch和git pull都可以用来更新本地库,它们之间有什么区别呢 ...
- Git fetch和git pull的区别(转)
原文: http://www.tech126.com/git-fetch-pull/ Git中从远程的分支获取最新的版本到本地有这样2个命令:1. git fetch:相当于是从远程获取最新版本到本地 ...
- 关于git fetch 和git pull 的区别
1.fetch 相当于是从远程获取最新版本呢到本地,不会自动merge. git fetch origin master:tmpgit diff tmp git merge tmp 2. git pu ...
- 2.git使用之git fetch和git push的区别
. git fetch:相当于是从远程获取最新版本到本地,不会自动merge git fetch origin master git log -p master..origin/master git ...
- git fetch 、git pull 与 git pull --rebase
1. git fetch 与 git pull 都是从远程拉取代码到本地,git fetch只是拉取到本地,git pull不仅拉取到本地还merge到本地分支中.所以git pull是git fet ...
随机推荐
- Shell命令-文件及内容处理之vi、vim
文件及内容处理 - vi.vim 1.Linux vi/vim 所有的 Unix Like 系统都会内建 vi 文书编辑器,其他的文书编辑器则不一定会存在. 但是目前我们使用比较多的是 vim 编辑器 ...
- jvm学习一:类加载过程详解
(自学笔记,持续更新,欢迎指正) 我们都知道一个java程序运行要经过编译和执行,但是这太概括了,中间还有很多步骤,今天来说说类加载 学完类加载之后,java运行过程就可以分为 编译 > 类 ...
- nginx(一)初识nginx
什么是nginx?Nginx (engine x) 是一款轻量级的Web 服务器 .反向代理服务器及电子邮件(IMAP/POP3)代理服务器. Nginx应用场景(都很常用): 1:http服务器.N ...
- JarvisOJ Misc shell流量分析
分析一下shell流量,得到flag 看着一大推的数据记录头都大了,并没有什么wireshark的使用经验,开始胡搞 首先用notepad++打开,搜索flag字样找到了一个类似于python脚本的东 ...
- bzoj 4571: [Scoi2016]美味 (主席树)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=4571 题面; 4571: [Scoi2016]美味 Time Limit: 30 Sec ...
- rest framework 序列化
serializers 序列化组件 可以实现很轻松的互相转换,最常用的组件 ,用量最大的组件 源码位置 rest_framework.serializers 源码中需要用到的 rest_fram ...
- <数据结构基础学习>(三)Part 2 队列
一.队列 Queue 队列也是一种线性结构 相比数组,队列对应的操作是数组的子集 只能从一端(队尾)添加元素,只能从另一端(队首)取出元素. (排队) 队列是一种先进先出的数据结构(先到先得)FIFO ...
- 使用Flink实现索引数据到Elasticsearch
使用Flink实现索引数据到Elasticsearch 2018-07-28 23:16:36 Yanjun 使用Flink处理数据时,可以基于Flink提供的批式处理(Batch Proce ...
- 三步解决fiddler升级后https无法通过证书验证问题
有时候使用fiddler时,https页面会出现错误提示,我们可以这样设置来避免错误 第一步:去掉https的抓取 Tools>Option 去掉Capture HTTPS CONNECTs 的 ...
- [物理学与PDEs]第1章习题15 媒介中电磁场的电磁动量密度向量与电磁动量流密度张量
对媒质中的电磁场, 推导其电磁动量密度向量及电磁动量流密度张量的表达式 (7. 47) 及 (7. 48). 解答: 由 $$\beex \bea \cfrac{\rd}{\rd t}\int_\Om ...