Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【GIT相关】解决终端命令行无效不存在的分支名称自动补全的问题 #13

Open
dabing1022 opened this issue Apr 26, 2016 · 0 comments

Comments

@dabing1022
Copy link
Owner

dabing1022 commented Apr 26, 2016

问题描述

远程分支已经将分支AAABBB删除,本地有个分支叫ABBB,当在终端中输入A,然后用Tab键自动补全的时候,老是把AAABBB给候选出来。很纳闷。远程分支AAABBB和本地分支AAABBB都已经被我删除,为什么还会补全提示呢?

例子

当前本地和所有的远程分支 以及 那些已经【死亡的无效的】分支

GitLab/Carpooling_iOS git:(F_Route) ▶ git br -a
* F_Route
  I_chat_module
  developer
  master
  remotes/origin/B_DIDA-8432
  remotes/origin/B_DIDA-8553
  remotes/origin/B_DIDA-8591
  remotes/origin/B_DIDA-8598
  remotes/origin/B_DIDA-8617/8504
  remotes/origin/B_DIDA-8691
  remotes/origin/B_DIDA-9156
  remotes/origin/B_DIDA_8504
  remotes/origin/B_DIDA_9156
  remotes/origin/B_Friend_Reddot
  remotes/origin/B_fix_booksetting
  remotes/origin/B_fix_chat_polling_timer
  remotes/origin/B_fix_hole_guide_position
  remotes/origin/B_fix_messageLeaving
  remotes/origin/B_fix_today_widget
  remotes/origin/B_fix_trip_cell
  remotes/origin/B_fix_trip_cell_related_error
  remotes/origin/B_smallfix
  remotes/origin/B_someFix
  remotes/origin/B_some_small_fix
  remotes/origin/F_Browser_Web_View
  remotes/origin/F_DIDA-8250
  remotes/origin/F_DIDA-8702
  remotes/origin/F_DIDA_8076
  remotes/origin/F_DIDA_8365
  remotes/origin/F_EZhiFu
  remotes/origin/F_LoginWaterMarkView
  remotes/origin/F_NewWelcomePages
  remotes/origin/F_New_Book_Passenger
  remotes/origin/F_Route
  remotes/origin/F_TmpChatPrivacyControl
  remotes/origin/F_cancel_hide_recent_chat_logic
  remotes/origin/F_delete_nearby_drivers
  remotes/origin/F_replace_welcome_page
  remotes/origin/F_text_modify
  remotes/origin/HEAD -> origin/master
  remotes/origin/I_chat_module
  remotes/origin/I_trip_waiting
  remotes/origin/developer
  remotes/origin/master
  remotes/origin/tmpChatPrivacyControl

解决方法

git fetch --prune --all

prune英文单词为“剪枝”的意思,这个命令会将远程已经不存在的分支删除掉

GitLab/Carpooling_iOS git:(F_Route) ▶ git fetch --prune --all
Fetching origin
From ssh://gitlab.didapinche.com:9122/mobile/Carpooling_iOS
 x [deleted]         (none)     -> origin/B_DIDA-8432
 x [deleted]         (none)     -> origin/B_DIDA-8553
 x [deleted]         (none)     -> origin/B_DIDA-8591
 x [deleted]         (none)     -> origin/B_DIDA-8598
 x [deleted]         (none)     -> origin/B_DIDA-8617/8504
 x [deleted]         (none)     -> origin/B_DIDA-8691
 x [deleted]         (none)     -> origin/B_DIDA-9156
 x [deleted]         (none)     -> origin/B_DIDA_8504
 x [deleted]         (none)     -> origin/B_Friend_Reddot
 x [deleted]         (none)     -> origin/B_fix_booksetting
 x [deleted]         (none)     -> origin/B_fix_chat_polling_timer
 x [deleted]         (none)     -> origin/B_fix_hole_guide_position
 x [deleted]         (none)     -> origin/B_fix_messageLeaving
 x [deleted]         (none)     -> origin/B_fix_today_widget
 x [deleted]         (none)     -> origin/B_fix_trip_cell
 x [deleted]         (none)     -> origin/B_fix_trip_cell_related_error
 x [deleted]         (none)     -> origin/B_smallfix
 x [deleted]         (none)     -> origin/B_someFix
 x [deleted]         (none)     -> origin/B_some_small_fix
 x [deleted]         (none)     -> origin/F_DIDA-8250
 x [deleted]         (none)     -> origin/F_DIDA-8702
 x [deleted]         (none)     -> origin/F_DIDA_8076
 x [deleted]         (none)     -> origin/F_DIDA_8365
 x [deleted]         (none)     -> origin/F_EZhiFu
 x [deleted]         (none)     -> origin/F_LoginWaterMarkView
 x [deleted]         (none)     -> origin/F_NewWelcomePages
 x [deleted]         (none)     -> origin/F_TmpChatPrivacyControl
 x [deleted]         (none)     -> origin/F_cancel_hide_recent_chat_logic
 x [deleted]         (none)     -> origin/F_delete_nearby_drivers
 x [deleted]         (none)     -> origin/F_replace_welcome_page
 x [deleted]         (none)     -> origin/F_text_modify
 x [deleted]         (none)     -> origin/I_trip_waiting
 x [deleted]         (none)     -> origin/tmpChatPrivacyControl

再来看看吧:)

GitLab/Carpooling_iOS git:(F_Route) ▶ git br -a
* F_Route
  I_chat_module
  developer
  master
  remotes/origin/B_DIDA_9156
  remotes/origin/F_Browser_Web_View
  remotes/origin/F_MyOrderList
  remotes/origin/F_New_Book_Passenger
  remotes/origin/F_Route
  remotes/origin/HEAD -> origin/master
  remotes/origin/I_chat_module
  remotes/origin/R_Order_Info
  remotes/origin/developer
  remotes/origin/master

一些僵尸分支已经被删除了,这下自动补全就不会再补全那些分支名称了 。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant