Day 5 - Trim your branches

Wow, didn’t realize so many local branches stick around. Will definitely use git fetch --prune going forward. At least my local is cleaned up a bit.

Still have way a lot of branches in origin to go through but that will take some co-ordination with coworkers to start making progress on that.

Oh wow. Deleted 33 remote already-merged branches (across many projects). Good riddance.

I was able to git rid of about 30 local branches across projects. One thing I found for a project that switched its primary branch from master to main last year: I forgot to re-assign HEAD to main. Fixed with

git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
1 Like

Thanks for the additional tips.

I often run this

git fetch \
  && git branch --merged \
  | egrep -v "(^\*|trunk)" \
  | xargs git branch -d

Where trunk is the name of the base branch for the repo I’m in.

I split it here for readability but practically I have it as a oneline that I can easily find when searching the terminal history with fzf.

Old tracking branches pruned and handful of old topic branches deleted.

Great week! Looking forward to next week!

My Local repo was filled with junk branches before. Thanks for the tips Have cleaned up all my local repo

I tend to prune my branches regularly and so didn’t have much to do here, however still a great reminder to keep things clean. Thanks for the great first week, looking forward to the next!

I regularly prune my branches, but thanks for the heads-up!

AWESOME! I’ve just removed a stale Laravel 5.7 branch <3

went through and did this against 3 repos. Also cleaned up my local branches!

Bit late, but did this yesterday. Turfed ~7 branches on my dotfiles repo in Github and am now down to just 1 branch.

Forgot to post! I love in Github the https://github.com/{your_org}/{your_repo}/branches/yours to take it further.

1 Like

Nice pure git/shell commands there.

I encountered git-town a while back which adds the wonderful additional git commands like prune-branches which works very much the same way (even asks you what the base branch is the first time and remembers).

1 Like

Deleted a pair of local branches

I deleted the only extra private branch — where the feature had already been implemented in master.

Like many others here I clean up my local merged branches often with a git helper that does the clean up. I also went through stale branches listed in our GitHub repo to remove them. :scissors: About 40 old branches were removed! :slight_smile:

Really useful! I always just ran git branch to see what is local, but this never showed these hidden tracking branches. Thanks!

my local branches I clean up regularly. and have to admit, to my surprise, at work the remote branches were also cleaned up. Only found one to delete.

Every day is a school day here. It was very pleasing to see the track of a lot of completed work in those branches that no longer needed to be tracked!