git分支跳主分支
Maintenance is incredibly important in any project, but if you want to take your professionalism to the next level, you should keep your git environment in shape. Unfortunately I'm not that guy -- I leave git branches laying around, even after they've been merged into master
. GitHub even provides a button to do the cleanup but I can't be bothered. Not good.
在任何项目中,维护都是非常重要的,但是如果您想将自己的专业水平提高到一个新水平,则应保持git环境的良好状态。 不幸的是,我不是那个家伙-即使git分支合并到master
之后,我仍然会留下它们。 GitHub甚至提供了一个按钮来进行清理,但是我不为所动。 不好。
When you're ready to do some real cleanup on a repository, throw this at it:
当您准备对存储库进行一些真正的清理时,将其扔给它:
-
- git branch | grep -v "master" | sed 's/^[ *]*//' | sed 's/^/git branch -d /' | bash
The shell command above deletes every branch in your local checkout except for master
branch. This is a dangerous script but you could always check out a given branch from a remote like GitHub if you happen to need it!
上面的shell命令删除本地结帐中除master
分支以外的每个分支。 这是一个危险的脚本,但是如果您碰巧需要它,可以随时从GitHub之类的远程平台签出给定的分支!
git分支跳主分支