更新时间:2023-11-22 12:01:58
您可以使用以下命令删除这些分支:
git push origin:branch_name
删除 BranchA
分支:
git push origin:BranchA
删除 origin / BranchA
分支:
git push origin:origin / BranchA
另外你可以使用 git branch -dr BranchA
等等。
删除除 BranchA
和 origin / BranchA
。您可能已经删除了 origin
remote,在这种情况下,您应该删除 remotes
remote并重新添加它为来源
远程。
I have moved an SVN repo to Git and probably due to a number of clonings, I'm now left with a bunch of branches that look like
BranchA
origin/BranchA
remotes/BranchA
remotes/origin/BranchA
remotes/origin/origin/BranchA
i.e. the same branch is listed a number of times. How can I clean this mess up. There are > 50 branches, some are not needed at all, and for the rest I'd be happy with just having them once.
EDIT:
This is what git remote show origin looks like for a certain case:
Remote branches:
BranchA tracked
origin/BranchA tracked
...
Local branches configured for 'git pull':
origin/BranchA merges with remote BranchA
...
Local refs configured for 'git push':
BranchA pushes to BranchA (up to date)
origin/BranchA pushes to origin/BranchA (up to date)
You can remove these branches by using this command:
git push origin :branch_name
To remove the BranchA
branch:
git push origin :BranchA
To remove the origin/BranchA
branch:
git push origin :origin/BranchA
Alternatively you could use git branch -dr BranchA
and so on.
Remove every branch except BranchA
and origin/BranchA
. You may have deleted the origin
remote, in which case you should remove the remotes
remote and re-add it as the origin
remote.