X-Git-Url: https://git.danieliu.xyz/?p=dotfiles.git;a=blobdiff_plain;f=Scripts%2Fgit-pushall;h=0d7def61399ee9382740e8b38a4d9512f58c9d63;hp=9fd1967f3e71dd2619d36b04ab3f47058b7d2424;hb=366f6e01929c651e868d008521bf56cc8d1414c2;hpb=1822d5e6d2af0a9706aa3fa95244afeb6308db28 diff --git a/Scripts/git-pushall b/Scripts/git-pushall index 9fd1967..0d7def6 100755 --- a/Scripts/git-pushall +++ b/Scripts/git-pushall @@ -1,12 +1,16 @@ #!/bin/sh -# reads the config file and pushes to all the remotes +# you can pass in git parameters to this script too +# e.g +# git-pushall git --git-dir=$HOME/.dotfiles --work-tree=$HOME -config_path="$(git rev-parse --show-toplevel)/.git/config" 2>/dev/null +cmd="$@" +[ -z "$cmd" ] && cmd="git" +config_path="$($cmd config --local -l)" 2>/dev/null [ ! "$?" = 0 ] && echo "Failed: not a git repo." && exit 1 -[ -z "$1" ] && echo "Failed: Please supply a branch to push to." && exit 1 -# look for all remotes -cat "$config_path" | sed '/^\[remote "/!d; s/^\[remote "//; s/"]$//' |\ - xargs -I _ git push _ "$1" +echo "$config_path" | grep '^remote.*.url=' |\ + sed 's/^remote.*.url=//' |\ + xargs printf "$cmd push %s master\n" |\ +