Git 跟踪大文件优化
Summary: Author: 张亚飞 | Read Time: 2 minute read | Published: 2020-03-15
Filed under
—
Categories:
Linux
—
Tags:
Note,
Git 大文件清理
执行 git fetch 报错 error: there are still refs under 'refs/remotes/origin
Thu Mar 16 10:23:01 worker@bjy-idc-brtc-web-test01:~/builder/OpenDocs$ git fetch
error: there are still refs under 'refs/remotes/origin/blive'
From git.baijiashilian.com:LLL/brtc/OpenDocs
! [new branch] blive -> origin/blive (unable to update local ref)
查看本地分支,可以看到有一个名为 remotes/origin/blive/android-doc
的分支和这个新的分支 blive
有重叠(使用路径/分割)
Thu Mar 16 10:24:31 worker@bjy-idc-brtc-web-test01:~/builder/OpenDocs$ git branch -a
deploy/beta
deploy/test
* master
remotes/origin/HEAD -> origin/master
remotes/origin/blive/android-doc
remotes/origin/deploy/beta
remotes/origin/deploy/test
remotes/origin/dev
remotes/origin/huangrui-master-patch-46168
remotes/origin/jack/20230104_update_transcode
remotes/origin/liubo/fixMirrorInlineDoc
remotes/origin/master
remotes/origin/resources
remotes/origin/xuyu/brtc_android_doc
remotes/origin/xyp/blivedoc
查看远程分支 blive/android-doc
发现并不存在,本地没有同步删除,可以把本地 remotes/origin/blive/android-doc
分支删掉
执行 git prune
发现并没有什么用
使用命令 git remote show origin
比对 remote
和 origin
分支
Thu Mar 16 10:23:18 worker@bjy-idc-brtc-web-test01:~/builder/OpenDocs$ git remote show origin
* remote origin
Fetch URL: git@git.baijiashilian.com:LLL/brtc/OpenDocs.git
Push URL: git@git.baijiashilian.com:LLL/brtc/OpenDocs.git
HEAD branch: master
Remote branches:
blive new (next fetch will store in remotes/origin)
deploy/beta tracked
deploy/test tracked
dev tracked
huangrui-master-patch-46168 tracked
jack/20230104_update_transcode tracked
liubo/fixMirrorInlineDoc tracked
master tracked
refs/remotes/origin/blive/android-doc stale (use 'git remote prune' to remove)
refs/remotes/origin/xuyu/brtc_android_doc stale (use 'git remote prune' to remove)
resources tracked
xyp/blivedoc tracked
Local branches configured for 'git pull':
deploy/beta merges with remote deploy/beta
deploy/test merges with remote deploy/test
master merges with remote master
Local refs configured for 'git push':
deploy/beta pushes to deploy/beta (fast-forwardable)
deploy/test pushes to deploy/test (local out of date)
master pushes to master (fast-forwardable)
发现有两个 refs/remotes/origin
备注信息为 (use 'git remote prune' to remove)
,应该是可以删除
查看本地所有分钟
Thu Mar 16 10:24:31 worker@bjy-idc-brtc-web-test01:~/builder/OpenDocs$ git branch -a
deploy/beta
deploy/test
* master
remotes/origin/HEAD -> origin/master
remotes/origin/blive/android-doc
remotes/origin/deploy/beta
remotes/origin/deploy/test
remotes/origin/dev
remotes/origin/huangrui-master-patch-46168
remotes/origin/jack/20230104_update_transcode
remotes/origin/liubo/fixMirrorInlineDoc
remotes/origin/master
remotes/origin/resources
remotes/origin/xuyu/brtc_android_doc
remotes/origin/xyp/blivedoc
执行 git remote prune origin
清理分支,也可以执行 git remote prune origin --dry-run
提前预览
Thu Mar 16 10:25:17 worker@bjy-idc-brtc-web-test01:~/builder/OpenDocs$ git remote prune origin
Pruning origin
URL: git@git.baijiashilian.com:LLL/brtc/OpenDocs.git
* [pruned] origin/blive/android-doc
* [pruned] origin/xuyu/brtc_android_doc
发现已经清理
再此查看本地分支,已经没有了 origin/blive/android-doc
和 origin/xuyu/brtc_android_doc
Thu Mar 16 10:25:39 worker@bjy-idc-brtc-web-test01:~/builder/OpenDocs$ git branch -a
deploy/beta
deploy/test
* master
remotes/origin/HEAD -> origin/master
remotes/origin/deploy/beta
remotes/origin/deploy/test
remotes/origin/dev
remotes/origin/huangrui-master-patch-46168
remotes/origin/jack/20230104_update_transcode
remotes/origin/liubo/fixMirrorInlineDoc
remotes/origin/master
remotes/origin/resources
remotes/origin/xyp/blivedoc
再次执行 git fetch
拉取成功
Thu Mar 16 10:25:49 worker@bjy-idc-brtc-web-test01:~/builder/OpenDocs$ git fetch
From git.baijiashilian.com:LLL/brtc/OpenDocs
* [new branch] blive -> origin/blive
查看使用 git pull
也会有相同的问题,分支名尽量不要使用路径符(/)
Comments