Skip to content

Instantly share code, notes, and snippets.

@azrsh
Last active November 7, 2022 05:25
Show Gist options
  • Save azrsh/46267d1a8e245d9001d6f79a30797c5d to your computer and use it in GitHub Desktop.
Save azrsh/46267d1a8e245d9001d6f79a30797c5d to your computer and use it in GitHub Desktop.
origin の デフォルトブランチを取得する / マージ済みブランチを削除する
#!/bin/bash
set -euCo pipefail
function main() {
local default_branch="$(git default-branch)"
git branch -d $(git branch --merged "${default_branch}" | grep -vE "\*|${default_branch}")
}
main
#!/bin/bash
set -euCo pipefail
git remote show origin | grep -E '^\s*HEAD branch: \w+$' | awk '{print $NF}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment