Sync Deleted Git Branches between Local and Remote
紀錄 local 和 remote 如何同步刪除 git branch
Delete Remote Branches From Local
- 刪除 remote branch 前不需要先刪除 local branch
git push REMOTE_NAME --delete BRANCH_NAME
Sync Branches Deleted at Remote
- Git 預設在 local pull/fetch 時, 不會自動刪除 remote 已刪除的 branch.
需要下指令:
git remote prune REMOTE_NAME
或是在 .git/config
設定:
git config remote.BRANCH_NAME.prune true
- 若刪除的 remote branch 已在 local checkout, 則 local branch 仍需手動刪除
Reference
Git
Written on
March
28th,
2022
by
Borting