e-i*_*ael 6 git bitbucket git-flow pull-request git-branch
我在本地的环境:
git-flow脚步
feature x在Sourcetree中创建一个,然后添加代码。commit包括选项create a pull request和对分支push的更改。feature xremotepull request我中选择 的选项Close {branch} after the pull request is merged。pull request然后将其合并到develop分支中。pull对我当地的分支机构进行了新的更改develop。注意pull request在将代码合并到 之前检查代码很重要develop,所以问题是:
有什么方法可以在创建后自动删除本地feature x分支吗?pulldevelop
*我尝试过,fetch但它不起作用。
处理此问题的一种简单的非自动化方法是定期在本地存储库中运行分支清理命令,例如
# to be executed with your "main" stable branch checked out
git branch -d $(git branch --merged)
Run Code Online (Sandbox Code Playgroud)
它将删除每个已合并的本地分支(即那些没有“尚未合并”提交的分支)。因此,所有通过拉取请求合并的分支都将被删除,但不会删除最近(未审查/未合并)提交的少数分支。
注意:如果您的策略是根据拉取请求压缩提交,那么这不是一个合适的解决方案,因为您的本地分支仍然具有原始(压缩前)提交,因此它们不会被视为合并,也不会被删除。