7

How do you clean up branches while working with PR ?!

It’s a nightmare. For each “bug” or feture there is a pull request created. As far as I know you MUST create a branch.

It’s easy to clean up GitHub (I’m just deleting branch after accepting PR. Which actually doesn’t even delete it for X days or something).

But local branches. OMG. It takes me at least 10 min/week to clean up and some of our devs don’t bother. They literally have 50+ local branches.

How do you manage that ?

I’m just about to write a script which deletes every local branch except selected (Yep UI with list of branches). But seems like overkill.

Comments
  • 2
    If your flow can allow it, feature/bug braches should stay locally or work in forks so the fork can be a mess but have 1 branch (staging / develop) that you do the PRs from up to the main repo (upstream), Merge the fork branches (feature/x -> staging) delete the feature branch, then do a merge from fork.staging to upstream.staging

    Keeps things somewhat organized and you don't end up with countless branches in your deployable repo.
  • 1
    @C0D4 Thanks.
    This is mostly how we work. But it doesn’t eliminate the need for local branches.

    We have :

    Master : release branch. Tested, validated. Can be published in production any time. Bugs PR are integrated in this branch

    Version branches: (Something like 2.14.1). All features developed for this version are integrated via Pull request to this branch. When version is ready, it’s integrated into master via a PR.

    I consider removing “version” branches. May help to reduce number of branches created.

    My goal is to make it as transparent as possible for developers. PR creation is already automated (let’s say you fix a bug : You start in master, you keep working and testing localy in master. Finished ? Run a power shell script which will : create new branch, commit your code, push branch, create PR, switch you back to master)

    Now I would love to include “unused branch deletion” into the same script.
  • 3
    are you using git? when yes, then use this command here locally on your machine which will delete all branches which do not have an upstream branch in origin:

    git remote prune origin
  • 2
    Embrace the branch. It is the reason git was created
  • 0
Add Comment