Skip to content

Instantly share code, notes, and snippets.

@ChrisOwen101
Last active July 29, 2021 20:57
Show Gist options
  • Save ChrisOwen101/84d82f03a60ce19f7f154a7b815fa265 to your computer and use it in GitHub Desktop.
Save ChrisOwen101/84d82f03a60ce19f7f154a7b815fa265 to your computer and use it in GitHub Desktop.
How to Batch Update All Coursework Repos

This is a really hacky way to update all of the Coursework Repos from the Template repo. It involves:

  1. Cloning every coursework repo
  2. cd into each of them
  3. Add the template repo as a remote
  4. Fetch, pull and marge everything in a slightly unsafe way
  5. push everything
  6. cd out

This methodology follows a single core principle:

"If it's stupid, but it works, then it isn't stupid"

I wrote a simple bash script to be able to do this on Windows that might provide a guide for doing this on other platforms.

set list=JavaScript-Core-1-Coursework-Week1 JavaScript-Core-1-Coursework-Week2 JavaScript-Core-1-Coursework-Week3 JavaScript-Core-2-Coursework-Week1 JavaScript-Core-2-Coursework-Week2 JavaScript-Core-3-Coursework-Week3 JavaScript-Core-3-Coursework-Week1 JavaScript-Core-3-Coursework-Week2 JavaScript-Core-3-Coursework-Week3 HTML-CSS-Coursework-Week1 HTML-CSS-Coursework-Week2 HTML-CSS-Coursework-Week3 SQL-Coursework-Week1 SQL-Coursework-Week2 SQL-Coursework-Week3 MongoDB-Coursework-Week1-2 MongoDB-Coursework-Week3 node-challenge-quote-server node-challenge-chat-server node-challenge-hotel-server

for %%a in (%list%) do (
 git clone "https://github.com/CodeYourFuture/${%%a}.git"
 cd %%a
 git remote add template https://github.com/CodeYourFuture/CYF-Coursework-Template.git
 git fetch --all
 git pull
 git merge template/main --allow-unrelated-histories --no-edit
 git push
 cd ..
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment