Skip to content

Instantly share code, notes, and snippets.

@edugon
Last active April 2, 2020 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edugon/8dee2e7b32d5a8fcda8a1d16b59f3993 to your computer and use it in GitHub Desktop.
Save edugon/8dee2e7b32d5a8fcda8a1d16b59f3993 to your computer and use it in GitHub Desktop.
Aliases to show or delete local branches that are not tracking remote anymore.
# The commands will match "TD" pattern as branch name and "gone]" to check if branches are untracking.
# Note: Depending on language you have in your git client, "gone]" part may change to e.g. "desaparecido]".
# WARNING: In case the branch has "gone]" in some commit, prune command will also delete it.
# Same happens for unmerged branches, change it to "git branch -d" for a safer usage.
alias git_show_untracking="git branch -vv | awk '\$3~/TD/ && \$4~/gone]/ {print \$1}'"
alias git_prune_untracking="git branch -vv | awk '\$3~/TD/ && \$4~/gone]/ {print \$1}' | xargs -n1 git branch -D"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment