git fetch --prune
Published on 09 Apr 2020
A very handy git command is git fetch --prune
.
For example, there were quite a few branches that had been deleted from remote, and also on local, but which still showed up when I tab-completed on my local:
$ git checkout BE_
BE_api_documentation_FEATURE_1mrttw BE_routes_controllers_FIX_1mweqd
BE_collection_csv_FEATURE_1mrtux BE_rswag_FIX_1mwvhk
BE_email_messages_FEATURE_1mrtuu BE_rubocop_FIX_1mvrf0
BE_haikunator_FEATURE_1mumnd BE_sanity_check_FIX_1mw7h0
BE_haikunator_FIX_1mwm8v BE_scope_teams_users_FEATURE_1mwvhq
So I ran this command:
$ git fetch --prune
From github.com:chameleoncreator/chameleon_feedback
- [deleted] (none) -> origin/BE_api_documentation_FEATURE_1mrttw
- [deleted] (none) -> origin/BE_collection_csv_FEATURE_1mrtux
- [deleted] (none) -> origin/BE_haikunator_FEATURE_1mumnd
- [deleted] (none) -> origin/BE_haikunator_FIX_1mwm8v
- [deleted] (none) -> origin/BE_routes_controllers_FIX_1mweqd
- [deleted] (none) -> origin/BE_rubocop_FIX_1mvrf0
- [deleted] (none) -> origin/BE_sanity_check_FIX_1mw7h0
- [deleted] (none) -> origin/api_doc_FEATURE_1mrttw
- [deleted] (none) -> origin/collection_responses_api_endpoint_FEATURE_1mrttu
- [deleted] (none) -> origin/create_collections_ui_FEATURE_1mr8nw
- [deleted] (none) -> origin/fix_routes_err_FEATURE_1mupbr
- [deleted] (none) -> origin/make_current_tests_pass_FEATURE_1mu69g
- [deleted] (none) -> origin/make_deployment_happen_with_dev-FEATURE-1mwpye
- [deleted] (none) -> origin/quick-brand-update-FEATURE-1mwfft
And now when I tab-complete a git checkout
:
$ git checkout BE_
BE_email_messages_FEATURE_1mrtuu BE_scope_teams_users_FEATURE_1mwvhq
BE_rswag_FIX_1mwvhk
all tags
activerecord android annoyances api apt arch array artix atom az3w backend bash blog browser bug callback career cli cloud code coding config configuration cp crud css database db design devops django email erp filter fugitive gif gist git gnome grep hebrew http ide isbn-fetcher iso javascript job search js kanban kanban\ kindle koans linux logger manjaro map markdown microservices mobi mtp neovim nodejs packages pastbin patch post python rails reduce refactoring rest routes rspec ruby scripting security sed shell sql string_replacement study tdd terminal testing version_control vim walkthrough workflow