Skip to content

jtzero/git-cleanup-merged-pr-branches

Repository files navigation

GCMPB git-cleanup-merged-pr-branches

broom

pipeline status

Installation

Dependencies

  1. One or more CLI's that correspond to the server you are using:
  2. gnu-coreutils >= 8.32
  3. git >= 2.40.0
  4. jq ~> 1.6

Install globally as exclusive post-checkout git hook

Steps

  1. clone repo and set up git hooks and set gcmpb as the post-checkout hook
    git clone [email protected]:jtzero/git-cleanup-merged-pr-branches.git "${XDG_DATA_HOME:-${HOME}/.local/share}/git-cleanup-merged-pr-branches" --branch stable \
    && mkdir "${HOME}/.git-hooks" \
    && git config --global core.hooksPath "${HOME}/.git-hooks" \
    && ln -nfs "${XDG_DATA_HOME:-${HOME}/.local/share}/git-cleanup-merged-pr-branches/bin/git-cleanup-merged-pr-branches-git-hook" "${HOME}/.git-hooks/post-checkout"

Install globally as extendable post-checkout hook

Steps

  1. ensure git-cleanup-merged-pr-branches-git-hook is in your PATH varaible
  2. clone repo and set up git hooks
    git clone [email protected]:jtzero/git-cleanup-merged-pr-branches.git "${XDG_DATA_HOME:-${HOME}/.local/share}/git-cleanup-merged-pr-branches" --branch stable \
    && mkdir "${HOME}/.git-hooks" \
    && git config --global core.hooksPath "${HOME}/.git-hooks"
  3. copy the templates/custom-post-checkout-hook and past it into ~/.git-hooks/post-checkout
  4. chmod +x ~/.git-hooks/post-checkout
  5. modify below # other things

Install locally git hook

Steps

  1. cd into repo you want to add this as a hook to
  2. clone repo and set post-checkout to gcmpb
    git clone [email protected]:jtzero/git-cleanup-merged-pr-branches.git "${XDG_DATA_HOME:-${HOME}/.local/share}/git-cleanup-merged-pr-branches" --branch stable \
    && ln -nfs "${XDG_DATA_HOME:-${HOME}/.local/share}/git-cleanup-merged-pr-branches/bin/git-cleanup-merged-pr-branches-git-hook" "./.git/hooks/post-checkout"

Usage as post-checkout hook with first time log in

  • The first time you use the hook it will ask you to log in to the respective VCS server.
  • Then once you have switched branches, if any branches have a PR that has been merged or closed, the tui will ask you if you want to delete it.

asciicast

Usage Info

bin/git-cleanup-merged-pr-branches-git-hook help OR bin/git-cleanup-merged-pr-branches help

API's supported

  • Github
  • GitLab
  • Azure