git合并分支后,删除分支

It's common courtesy to keep your git branch list clean, especially when colleagues need to fetch your remote branches.  I'm a bit of a ... offender, when it comes to maintaining my git branch list.  My colleague John Karahalis is not, however, and he hooked me up with an awesome git alias for deleting branches that have been merged into master. Place the following within your .git/config file:

通常要保持git分支列表的清洁,尤其是当同事需要获取您的远程分支时。 当维护我的git分支列表时,我有点...冒犯者。 但是我的同事约翰·卡拉哈里斯 ( John Karahalis )却不是,他给我提供了一个很棒的git别名,用于删除已合并到master的分支。 将以下内容放入您的.git/config文件中:


[alias]
  delete-merged-branches = "!f() { git checkout --quiet master && git branch --merged | grep --invert-match '\\*' | xargs -n 1 git branch --delete; git checkout --quiet @{-1}; }; f"


You can run this command via:

您可以通过以下方式运行此命令:


git delete-merged-branches


The script worked masterfully -- all branches merged into master were gone and I was left to evaluate which local branches were left to send pull requests for.  Beautiful.  Keep this around if you're a lazy git-ter like me!

该脚本可以很好地工作-合并到master的所有分支都消失了,我被留下来评估剩下的本地分支要发送请求请求。 美丽。 如果您像我一样懒惰,请保持此状态!

翻译自: https://davidwalsh.name/delete-merged-branches-git

git合并分支后,删除分支

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐