Last active
October 31, 2018 16:18
-
-
Save JoshCheek/fee11883a8cdc6697eb3478fd9e03602 to your computer and use it in GitHub Desktop.
git-nuke: Delete remote and local branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# a variation on https://twitter.com/r00k/status/1057657001013100544 | |
function git-nuke() { | |
local local_branch="$1" | |
local upstream="$(git rev-parse --abbrev-ref "$local_branch"'@{upstream}')" | |
if [[ -n "$upstream" ]]; then | |
IFS=/ read remote_repo remote_branch <<<"$upstream" | |
git push "$remote_repo" --delete "$remote_branch" && git branch -D "$local_branch" | |
else | |
exit 1 | |
fi | |
} | |
git-nuke "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment