Created
July 15, 2016 21:15
-
-
Save meatballhat/1d3a6196c8614cb9ec7d75af7d134281 to your computer and use it in GitHub Desktop.
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 | |
set -o errexit | |
: ${GIT:=git} | |
__mainremote() { | |
if [[ "${REMOTE}" ]] ; then | |
echo "${REMOTE}" | |
return | |
fi | |
${GIT} config --local repo.mainremote 2>/dev/null || echo origin | |
} | |
__mainbranch() { | |
if [[ "${BRANCH}" ]] ; then | |
echo "${BRANCH}" | |
return | |
fi | |
${GIT} config --local repo.mainbranch 2>/dev/null || echo master | |
} | |
__delbranch() { | |
if [[ "${1}" ]] ; then | |
echo "${1}" | |
return | |
fi | |
${GIT} rev-parse --abbrev-ref HEAD | |
} | |
main() { | |
local delbranch="$(__delbranch "${1}")" | |
${GIT} checkout "$(__mainbranch)" | |
${GIT} pull | |
${GIT} remote prune "$(__mainremote)" | |
if [[ $delbranch ]] ; then | |
${GIT} branch -d "${delbranch}" | |
fi | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment