【问题标题】:How to automatically remove remote-tracking branch when the corresponding local branch is removed using git如何在使用git删除相应的本地分支时自动删除远程跟踪分支
【发布时间】:2015-07-29 21:35:40
【问题描述】:

当前设置:

$ git branch -a
* master
  feature
  remotes/origin/master
  remotes/origin/feature

feature 分支合并后,我想删除本地分支feature 和远程跟踪分支origin/feature。在这种情况下,服务器上的远程分支已经被删除。

我需要的命令是:

$ git branch -d features
$ git branch -d -r origin/features

有没有办法在删除相应的本地分支时自动触发第二条命令?有任何git-config 设置吗?

【问题讨论】:

    标签: git branch remote-branch


    【解决方案1】:

    如果你设置git config fetch.prune true,那么第二个命令可以是一个简单的git fetch

    这将修剪任何远程跟踪分支origin/feature,因为feature 已在服务器端删除。

    即使您不使用配置设置,git fetch --prune 也会这样做。

    在这两种情况下,优点是它将修剪服务器上已删除的任何远程跟踪分支(而不是仅一个分支)。

    【讨论】:

      猜你喜欢
      • 2014-06-09
      • 1970-01-01
      • 2016-07-08
      • 2021-08-22
      • 2011-12-05
      • 2011-01-01
      相关资源
      最近更新 更多