Last Updated: February 25, 2016
· viatropos

Push to github several repos at once from the command-line

Say you have a dozen repos (to make small, focused, single-purpose modules), and you are just going through and documenting them all. Maybe you jump back and forth between them and don't want to push to github every time you add a sentence or whatever. Instead, you wait until you're done on your documenting sprint, and then just want to push them all to GitHub. Here's one way to do that.

Add this to your ~/.bash_profile:

gc-all() {
  find . -type d -maxdepth 1 -exec sh -c "(cd {} && git add . && git commit -am \"$1\" && git push)" ';'

alias gc-all=gc-all

then reload it with this command:

source ~/.bash_profile

Now say your dozen repos are in the folder current directory. All you do is this:

gc-all "added some documentation"

And boom, it'll iterate through all your repos, commit the changes, and push each one to GitHub.