Last Updated: February 25, 2016
·
368
· erebusbat

Pushing sll Changes to all remotes

I frequently have multiple copies of my git repositories on different servers for backup purposes. I have tried ZSH brace expansion to do things like git push {origin,home} master but it would never work correctly.

I finally gave up and wrote this function and put it in my ZSH startup routine:

# Git Push All
function gpa(){
  for r in $(git remote); do
    echo "Pushing All Changes to $r";
    git push $r --all;
    echo "";
  done
}

This will enumerate all configured git remotes and push all changes to them. You might want to add a git push $r --tags; line as well.

Obviously this is not a one size fits all solution, but for when I need it there it is.

1 Response
Add your response

Or you can install hub ( http://hub.github.com ) and do exactly what you originally tried ( git push origin,home )

over 1 year ago ·