Github is a great place to store code. It is mainly a way to version control your codebase. As I was pushing code into a private repository for a client the other day I realized that I had over 100 repos out there.

There is no way I need to have that many! Plus a lot of those repos were created when I was going through tutorials and learning to code.

I started in PHP and then went to FreeCodeCamp to learn JavaScript. Those repos are definitely beyond out of date. You don’t leave rotten produce on the shelf. Time to do some cleanup.

But there is no way I was going to just delete the code to be lost forever, even though it is so horrendously out of date. I decided to pull everything into a few repos.

PHP Projects FreeCodeCamp Projects YouTube Projects

To make things even more fun I decided to write a script that would clone the repos automatically. There is a great package for that: Degit

Check out the code below:

const degit = require('degit');

const repos = [
  // put the names of the repos you want to clone into this array
];

repos.forEach(repo => {
  const emitter = degit(`rheajt/${repo}`, {
    force: true,
  });

  emitter.on('info', info => {
    console.log(info.message);
  });

  // i cloned all of the repos into a projects folder, but you can do whatever's clever
  emitter.clone(`./projects/${repo}`).then(() => {
    console.log('done');
  });
});