如何删除共享的远程git分支?

时间:2014-05-21 19:27:06

标签: git github

我的.git目录中的配置文件的内容如下:

     [core]
             repositoryformatversion = 0
             filemode = true
             bare = false
             logallrefupdates = true
             worktree = ../../src/PKGNAME
     [remote "origin"]
             url = ssh://git.COMPANYNAME.com:port/pkg/PKGNAME
             fetch = +refs/heads/*:refs/remotes/origin/*
     [remote "backup"]
             url = ssh://git.COMPANYNAME.com:port/pkg/PKGNAME/backup/username
             fetch = +refs/heads/*:refs/remotes/backup/*
             push = +refs/heads/*:refs/heads/*
     [remote "share"]
             url = ssh://git.COMPANYNAME.com:port/pkg/PKGNAME/share/username
             fetch = +refs/heads/*:refs/remotes/share/*
             push = +refs/heads/*:refs/heads/*
     [branch "integTests"]
             remote = origin
             merge = refs/heads/mainline
             rebase = true
     [branch "clean"]
             remote = origin
             merge = refs/heads/mainline
             rebase = true

我运行了git push,它共享了所有本地分支,甚至是那些未在此配置文件中列出的分支。输出是这样的:

   $ git push share
   Counting objects: 109, done.
   Delta compression using up to 2 threads.
   Compressing objects: 100% (45/45), done.
   Writing objects: 100% (100/100), 6.70 KiB | 0 bytes/s, done.
   Total 100 (delta 34), reused 0 (delta 0)
   To ssh://git.COMPANYNAME.com:port/pkg/PKGNAME/share/username
    * [new branch]      clean -> clean
    * [new branch]      fresh -> fresh
    * [new branch]      integTests -> integTests
    * [new branch]      mainline -> mainline

我想只分享我的主线分支。如何取消其余部分?

1 个答案:

答案 0 :(得分:1)

除了@janos的答案显示如何删除遥控器上错误推送的分支之外,您还想更改该遥控器的push规范,使其如下所示:

[remote "share"]
         url = ssh://git.COMPANYNAME.com:port/pkg/PKGNAME/share/username
         fetch = +refs/heads/*:refs/remotes/share/*
         push = +refs/heads/mainline:refs/heads/mainline

这样一来,唯一的分支git push会关注与share遥控器进行通信时的mainline分支......

编辑:结合@janos的建议删除遥控器上错误推送的分支:

  

您必须逐个删除其他人:

git push share :clean
git push share :fresh
git push share :integTests