哪些网站可以做英语等级试题,怎么做一淘宝客网站,商洛免费做网站公司,查法人信息的网站(Owed by: 春夜喜雨 http://blog.csdn.net/chunyexiyu)
最近使用git越来越多#xff0c;一些git的功能使用也更熟悉了一些。 之前使用了single-branch下载分支#xff0c;后来想取消掉#xff0c;但怎么做呢#xff0c;查了一些资料之后#xff0c;了解到了怎么做#x…(Owed by: 春夜喜雨 http://blog.csdn.net/chunyexiyu)
最近使用git越来越多一些git的功能使用也更熟悉了一些。 之前使用了single-branch下载分支后来想取消掉但怎么做呢查了一些资料之后了解到了怎么做特记录下来。
背景
所在的项目中一个库的分支非常多有50上以上的分支clone工程时也耗时比较长。下载的时候考虑着只用一个分支就指定了分支clone的工程。 操作语句形如 $ git clone -b mybranch --single-branch --depth 1 https://user192.168.0.101:8080/scm/git/demoproject local-folder-name 过了一段时间后发现单用这一个分支不够用了需要下载一个新的分支但通过 git branch -a 查看是会发现本地和远端都只有这一个分支存在。 形如 $ git branch *mybranch remotes/origin/mybranch 如何去除single-branch影响呢怎么能看到远端的所有分支呢也只有看到了远端的哪些其余的分支才能够去把远端的其他分支下载到本地来才能checkout来switch到另一个分支上去。
去除single-branch影响
如何去除single-branch影响我们先来看一看single-branch会对配置产生哪些影响呢 观察发现在.git/config有体现它的影响。 下面观察一个带single-branch 和 一个不带single-branch是这个配置文件的变化。
观察配置
不使用single-branch时的.git/config缺省配置
[remote origin]url http://username192.168.0.101:8080/scm/git/demoprojectfetch refs/heads/*:refs/remotes/origin/*
[branch mybranch]remote originmerge refs/heads/mybranch使用single-branch时的.git/config配置
[remote origin]url http://username192.168.0.1014:8080/scm/git/demoprojectfetch refs/heads/mybranch:refs/remotes/origin/mybranch
[branch mybranch]remote originmerge refs/heads/mybranch可以观察到差异体现在remote “origin“里面的fetch配置项上。
回退配置
对于回退时查阅资料发现也确实是来修改这个配置项的下面来看修改的方式。
设定配置[remote “origin“].fetch $ git config remote.origin.fetch “refs/heads/:refs/remotes/origin/” 重新获取origin信息通过fetch获取到所有的分支信息树结构 注意这一步如果库比较大分支比较多可能耗时会比较长 $ git fetch origin 观察远端分支会看到增加了很多 $ git branch -a *mybranch remotes/origin/mybranch remotes/origin/master … 去除single-branch后
经过上一步回退了single-branch。 此时这个本地库就和直接clone的一样了可以切换到拥有的所有分支了。
当然随之而来也会看到本地库所占的大小增加了很多。 linux下可以使用 du -sh 来查看目录所占的大小如果观察的话会发现增长了很多。 因为去除single-branch的话我们就和远程库保持一致了自然大小也会比较大了。
有利有弊去除single-branch后大小增加了但同时我们恢复了切换到所有其它分支的自由。
切换到其他分支方法
此时如果想要checkout到一个新的分支上就可以执行下面操作来做了 $ git checkout master 分支 master 设置为跟踪来自 origin 的远程分支 master 切换到一个新分支 ‘master’ 切换后就可以查看本地分支可以看到本地多了这个分支也切换到了这个分支 $ git branch master mybranch (Owed by: 春夜喜雨 http://blog.csdn.net/chunyexiyu)