[英]Git - Remove branches not on remote
所以我在shell中,我做了以下事情:
git fetch --all --prune
git reset --hard
git branch
以下列出
*master
branch a
branch b
在遙控器上,有兩個分支。 master
和branch a
。 我希望任何不在遙控器上的分支都從我的機器上消失。 什么是最簡單的方法我可以使所有已合並的額外分支消失而不刪除本地倉庫並重新下載? 對此沒有個別命令嗎?
要刪除本地分支,請調用git branch -d the_local_branch
如果git嘗試使用五行腳本為每個有用的東西實現按鈕,那么找到正確的按鈕需要更長的時間而不是編寫腳本。
git for-each-ref refs/heads \
--format='x=`git rev-parse -q --verify "%(upstream)"` \
|| echo git branch -d %(refname:short)' \
| sh -x
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.