-
-
Save gildas/dc8f4e7e40f7416c263813b35f2a8ba3 to your computer and use it in GitHub Desktop.
git push all remotes
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
# | |
# git push all and tags to origin or other repo | |
# | |
# This assumes git config push.default matching | |
function gpA { | |
local VERBOSE=${VERBOSE:-0} | |
while (( $# > 0 )); do | |
[[ $1 == --*=* ]] && set -- "${1%%=*}" "${1#*=}" "${@:2}" | |
case $1 in | |
--quiet) | |
VERBOSE=0 | |
;; | |
-v|--verbose) | |
VERBOSE=$((VERBOSE + 1)) | |
(( VERBOSE > 2 )) && set -o xtrace # trace commands before they are executed | |
;; | |
-?*|--*=) # Invalid options | |
;; | |
--) # Force end of options | |
shift | |
break | |
;; | |
*) # Positional Argument | |
ARGS+=( "$1" ) | |
;; | |
esac | |
shift | |
done | |
local remotes=( $(git remote -v | grep push | cut -f1) ) | |
for remote in ${remotes[@]}; do | |
(( VERBOSE )) && echo "Pushing to $remote" | |
git push $remote | |
(( VERBOSE )) && echo "Pushing tags to $remote" | |
git push --tags $remote | |
done | |
} | |
gpA "$@" | |
# vim: set syntax=zsh: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment