1

I have build up a bunch of local branches. I want to safely get rid of them. By safely, I mean I would like to only delete the local branches for the remotes have been merged and deleted.

I used gitlab to delete merged branches, however that leaves the local branches. I tried pruning, but it didn't seem to do what I expected.

I ran git branch -vv

  Branch_XYZ   82142af1 [origin/Branch_XYZ: gone] Some commit message
  Branch_XYZ2   82142af1 [origin/Branch_XYZ2: gone] Some commit message
  ...

I think all these ones are safe to delete, but I would like git to do it for all of them. I have like 30 or something. (Spring Cleaning Time)

GC

GC_
  • 448
  • 4
  • 23
  • If those branches have been merged in the remote repo, you just need to prune the tracking branches then. – Jeff Mercado Jun 05 '20 at 21:04
  • @JeffMercado Pruning just removes the reference to the remove branch or some useless junkn like that, not actually remove the local branch, – GC_ Jun 06 '20 at 19:01
  • Sorry, misread what I was seeing, didn't know git can list local branches and point out that the tracking branch is gone. Thought you were showing all tracking branches. – Jeff Mercado Jun 07 '20 at 00:01
  • @JeffMercado Pruning is silly, I not sure what it does, maybe it prunes remote branches, but not local. – GC_ Jun 10 '20 at 01:54
  • It removes the remote branches (`refs/remotes/**`) if the corresponding branch on the remote is deleted. Remote branches are separate from local branches and keeps track of what your local repo understands is on the remote. – Jeff Mercado Jun 10 '20 at 01:57

0 Answers0