清理远程Git分支

Mak*_*kis 2 git git-remote git-branch

我已经将一个SVN回购移动到Git,可能由于一些克隆,我现在留下了一堆看起来像的分支

BranchA
origin/BranchA
remotes/BranchA
remotes/origin/BranchA
remotes/origin/origin/BranchA
Run Code Online (Sandbox Code Playgroud)

即同一分支被列出多次.我怎样才能清理这个烂摊子.有大约50个分支,有些根本不需要,其余的我只会拥有它们一次.

编辑:

对于特定情况,这就是git remote show origin的样子:

Remote branches:
BranchA tracked
origin/BranchA tracked
Run Code Online (Sandbox Code Playgroud)

...

Local branches configured for 'git pull':
origin/BranchA merges with remote BranchA
Run Code Online (Sandbox Code Playgroud)

...

Local refs configured for 'git push':
BranchA pushes to BranchA (up to date)
origin/BranchA pushes to origin/BranchA (up to date)
Run Code Online (Sandbox Code Playgroud)

Rya*_*igg 5

您可以使用以下命令删除这些分支:

git push origin :branch_name
Run Code Online (Sandbox Code Playgroud)

删除BranchA分支:

git push origin :BranchA
Run Code Online (Sandbox Code Playgroud)

删除origin/BranchA分支:

git push origin :origin/BranchA
Run Code Online (Sandbox Code Playgroud)

或者你可以使用git branch -dr BranchA等等.

删除除BranchA和之外的所有分支origin/BranchA.您可能已删除了origin遥控器,在这种情况下,您应该移除remotes遥控器并将其重新添加为origin遥控器.