Skip to content

Instantly share code, notes, and snippets.

@Aprillion
Last active December 30, 2020 22:33
Show Gist options
  • Save Aprillion/bc2a5a4f2ca5d28a6115bbb06b88e145 to your computer and use it in GitHub Desktop.
Save Aprillion/bc2a5a4f2ca5d28a6115bbb06b88e145 to your computer and use it in GitHub Desktop.
How to make the same change in multiple GitHub repos

A concrete example how I automated a chore update of multiple repostitories that I do not own => to create pull requests (PRs) with the same simple change in each repo.

copy([
  ...new Set($$('h1 > a[href^="/kentcdodds/"]').map(el => `gh repo fork ${el.href}.git --clone --remote`))
].join('; '))
  • paste the shell command, review, and execute in the new directory
  • review that you have correct repos
  • display your browser and bash terminal side by side
  • make the small change in each directory and open new PRs in browser tabs (to review each before submitting)
ls -d */ | xargs -I {} bash -c "cd '{}' \
&& echo '.eslintcache' >> .gitignore \
&& git add . \
&& git commit -m 'chore: ignore .eslintcache' \
&& git push \
&& gh pr create --web"

Note: the double >> is important if you want to only modify the last line of file and not modify whole file with single >. Of course, you also need to modify your commit message to match your change 😉

@Aprillion
Copy link
Author

FTR this was a workaround for facebook/create-react-app#10161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment