Partially Script the Same Change in Multiple Git Repos

Published: Dec 9, 2021 • Updated: Dec 23, 2021

One of the disadvantages of a micro-service architecture is the config situation. Say you have 15 micro-services. Then say want to make the same change in each one. Well, now you have the pleasure of opening 15 pull requests.

This is one of those weird tasks where the time it takes to automate the thing outweighs the time it takes to do it manually.

Partially scripting the task can help, though. The first and last parts are copy-pasted into terminal. The middle part obviously varies per task.

  1. Set the main branch, feature branch, and commit message variables. Then make a branch off your main branch
  2. Make a checklist of things to do. Don’t hold this info in your head, you’re bound to forget something. Then do the things
  3. Commit and push the changes. Git will output a pull request URL for you. Profit
export main_branch="develop" && \
export feature_branch="some-name" && \
export commit_message="some message" && \
git checkout "${main_branch}" ; \
git pull origin "${main_branch}" && \
git checkout -b "${feature_branch}"


# CHECKLIST
# thing 1
# thing 2
# ...


git add --all && \
git commit -m "${commit_message}" && \
git push --set-upstream origin "${feature_branch}"