简体   繁体   English

Git - 删除不在远程的分支

[英]Git - Remove branches not on remote

So I'm in a shell and I do the following: 所以我在shell中,我做了以下事情:

git fetch --all --prune
git reset --hard
git branch

And the following is listed 以下列出

*master
branch a
branch b

On the remote, there are two branches. 在遥控器上,有两个分支。 master and branch a . masterbranch a I want any branches that aren't on the remote to be gone from my machine. 我希望任何不在遥控器上的分支都从我的机器上消失。 What's the simplest way I can make all extra branches that have been merged to disappear without deleting the local repo and re-downloading it? 什么是最简单的方法我可以使所有已合并的额外分支消失而不删除本地仓库并重新下载? Is there no individual command for that? 对此没有个别命令吗?

要删除本地分支,请调用git branch -d the_local_branch

If git tried to implement pushbuttons for every useful thing you could do with a five-line script, it'd take longer to find the right pushbutton than to just write the script. 如果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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM