git - 通过 pull 请求 merge 后如何删除本地分支? git-flow、bitbucket、sourcetree

标签 git bitbucket atlassian-sourcetree git-flow

我在本地的环境:

  • Git 连接 Bitbucket
  • Sourcetree git-flow

  • 脚步
  • 我在 Sourcetree 中创建了一个 feature x 然后我添加了代码。
  • 我做了一个 commit ,包括 create a pull requestpush 的选项,在 feature x 中对 remote 分支的更改。
  • pull request 中,我选择了 Close {branch} after the pull request is merged 选项。
  • Bitbucket 中,成员团队批准了 pull request,然后将其 merge 到 develop 分支中。
  • I pull 对本地 develop 分支的新更改。

  • 注意 在将代码 merge 到 pull request 之前通过 develop 检查代码很重要,所以问题是:

    feature x 中创建 pull 后,有没有办法自动删除我本地的 develop 分支?

    *我尝试使用 fetch 但它不起作用。

    最佳答案

    处理此问题的一种简单的非自动化方法是定期在本地存储库中运行分支清理命令,例如

    # to be executed with your "main" stable branch checked out
    git branch -d $(git branch --merged)
    

    它将删除每个已经 merge 的本地分支(即那些没有“尚未 merge ”提交的分支)。因此,通过 pull 请求 merge 的所有这些分支都将被删除,但不会删除最近(未审查/未 merge )提交的少数分支。

    注意:如果您的策略是根据 pull 请求压缩提交,这将不是一个合适的解决方案,因为您的本地分支仍然具有原始(压缩前)提交,因此它们不会被视为已 merge ,也不会被删除。

    关于git - 通过 pull 请求 merge 后如何删除本地分支? git-flow、bitbucket、sourcetree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59886213/

    相关文章:

    docker - 如何阻止 TeamCity 每次都重新构建 docker 依赖项?

    git - 如何在git中找到文件的最近提交者?

    Git 帮助命令不会在配置的浏览器中打开

    android - Eclipse Android 和 gitignore

    Git: merge 两个远程分支

    github - Git - 同一分支上的多个开发人员

    git - 如何在 SourceTree 中执行 git cherry-pick --continue?

    git - Sourcetree 将 HEAD 设置为 origin/master

    git - Sourcetree/GIT - pull 时无法锁定 ref/reference broken

    git - 在推送时将大型 repo 分成多个较小的 repo