All of the WordPress themes that I work on for iThemes are managed as Git repositories. Recently, we moved past the 100 repositories mark. That’s a lot of repositories to manage, and unfortunately, too many of those repositories contain duplicated information.
Later on, I might delve into how we use Git to manage our theme repos. For today, however, I’d like to focus on how I quickly and easily pushed up changes to more than a dozen repos in a single, albeit long, Bash command.
I had finished making updates to 16 Flexx repos, and I needed to push all of those changes up. Since I had multiple working repos in that folder, I was lucky that each of these repos began with the text “Flexx”. Also, since they are all part of the same series and need to keep the same version number, that simplified the tagging as all could be tagged as 2.5.0.
Given this information, I simply ran the following command from the directory that contained all the repository directories:
for i in `ls|grep Flexx`; do echo "--- Pushing $i"; cd $i; git commit -am '2.5.0' && git push && git tag 2.5.0 && git push --tags; cd ..; echo "--- Finished $i"; done
There’s a lot going on here, so I’ll break it up and explain what I’m doing.