Package: git-sweep-merged-and-stale
This is based on the excellentgit-sweep.I just addeddelete_stale_after_dayswhich allows you to specifydelete_stale_after_daysstale branches we need to delete.ie:git-sweep-merged-and-stalecleanup--delete_stale_after_days15will delete all Branches older than 15 days and those merged in Master.WARNING: When you delete branches with no active PR, you will lose access to the ability to restore the branch. Please back it up using Github Artifacts or
a copy of the branch prior to running this.This deletes branches that fulfil either of these:Merged into Master or the branch you specify bywhich_master_mainORBranches older than X days (specified bydelete_stale_after_days)This by default does not work until you set parameter action =cleanupTo install it run:pip install git-sweep-merged-and-stale || easy_install git-sweep-merged-and-staleThen to run it inpreviewmode:git-sweep-merged-and-stale preview --delete_stale_after_days 30Then to run it incleanupmode:git-sweep-merged-and-stale cleanup --delete_stale_after_days 30IntroductionA command-line tool that helps you clean up Git branches that have been merged
into master.One of the best features of Git is cheap branches. There are existing branching
models likeGitHub Flowand Vincent Driessen’sgit-flowthat describe
methods for using this feature.The problemYourmasterbranch is typically where all your code lands. All features
branches are meant to be short-lived and merged intomasteronce they are
completed.As time marches on, you can build upa long list of branches that are no
longer needed. They’ve been merged intomaster, what do we do with them
now?The answerUsinggit-sweep-merged-and-staleyou cansafely remove remote branches that have been
merged into master.To install it run:pip install git-sweep-merged-and-stale || easy_install git-sweep-merged-and-staleTry it for yourself (safely)To see a list of branches that git-sweep-merged-and-stale detects are merged into your master branch:You need to have your Git repository as your current working directory.$ cd myrepoThepreviewcommand doesn’t make any changes to your repo.$ git-sweep-merged-and-stale preview
Fetching from the remote
These branches have been merged into master:

  branch1
  branch2
  branch3
  branch4
  branch5

To delete them, run again with `git-sweep-merged-and-stale cleanup`If you are happy with the list, you can run the command that deletes these
branches from the remote,cleanup:$ git-sweep-merged-and-stale cleanup
Fetching from the remote
These branches have been merged into master:

  branch1
  branch2
  branch3
  branch4
  branch5

Delete these branches? (y/n) y
  deleting branch1 (done)
  deleting branch2 (done)
  deleting branch3 (done)
  deleting branch4 (done)
  deleting branch5 (done)

All done!

Tell everyone to run `git fetch --prune` to sync with this remote.
(you don't have to, yours is synced)Note: this can take a little time, it’s talking over the tubes to the remote.You can also give it a different name for your remote and master branches.$ git-sweep-merged-and-stale preview --master=develop --origin=github
...Tell it to skip thegit fetchthat it does by default.$ git-sweep-merged-and-stale preview --nofetch
These branches have been merged into master:

  branch1

To delete them, run again with `git-sweep-merged-and-stale cleanup --nofetch`Make it skip certain branches.$ git-sweep-merged-and-stale preview --skip=develop
Fetching from the remote
These branches have been merged into master:

  important-upgrade
  upgrade-libs
  derp-removal

To delete them, run again with `git-sweep-merged-and-stale cleanup --skip=develop`Once git-sweep-merged-and-stale finds the branches, you’ll be asked to confirm that you wish to
delete them.Delete these branches? (y/n)You can use the--forceoption to bypass this and start deleting
immediately.$ git-sweep-merged-and-stale cleanup --skip=develop --force
Fetching from the remote
These branches have been merged into master:

  important-upgrade
  upgrade-libs
  derp-removal

  deleting important-upgrade (done)
  deleting upgrade-libs (done)
  deleting derp-removal (done)

All done!

Tell everyone to run `git fetch --prune` to sync with this remote.
(you don't have to, yours is synced)Deleting local branchesYou can also clean up local branches by using simple hack:$ cd myrepo
$ git remote add local $(pwd)
$ git-sweep-merged-and-stale cleanup --origin=localDevelopmentI just usepytestto test this.RequirementsGitPython >= 3.6LicenseFriendly neighborhood MIT license.