DEV Community

Discussion on: Git garbage: what if your local have a lot of old branches?

Collapse
 
fpeluso profile image
Fabio Peluso

Have you tried this on branches that were not merged?

Collapse
 
jessekphillips profile image
Jesse Phillips

Lets make sure we are both talking about the same situation.

  • There is a local branch (not a tracking branch) in your repo
  • The branch has not been merged
  • The corresponding remote branch has been deleted (gone)
  • The branch on the remote was not merged

If this is in fact the situation we are discussing then here are some thoughts

  1. We may not care about the work done for that branch and it can be removed
  2. The remote branch was accidentally deleted and so we want to get those back up there and merged in

I think that once you have cleaned up the work that has been merged, it becomes an exercise in reviewing all branches and determining if they are desired and press to get items merged in that are ready. If you aren't ready to do such a review, leave the branches until you are.

Thread Thread
 
fpeluso profile image
Fabio Peluso

Yeah, almost! The forth bulletpoint is not always there. I really appreciate your comment, it is a very clean way to deal with the situation

Thread Thread
 
jessekphillips profile image
Jesse Phillips

If the branch was merged on the remote, then my approach will find it. It is the reason I switch to origin/master. Any other branch can also be used, which checks for what is merged into that branch.

Have a good Thanksgiving if you celebrate.