If you’re like me, you write a fair bit of a code, which means you have to interact with many Git repositories. If you’re also like me, chances are you have them in a directory called development/ or similar. It might even have some nested directories, something like this:
./allaboutcheetahs.info ./diceware ./docker/check-disk-space ./docker/health-check ./node/circuitbreaker-demo ./node/neural-network ./s3/bucket-sizes ./s3/disk-usage ./snowdrift ./ssh-to
So that’s cool, but let’s say that you get a new machine and you want replicate your development/ directory structure onto it? One way is to check out everything by hand, but that’s laborious and time consuming. A second way is to keep backups–and you should absolutely do this–but aside from challenges of restoring a single directory out of an entire archive, what if that backup doesn’t have the latest commits in it?
I can now offer a third way. I recently wrote a couple of scripts available on GitHub that can be used to extract Git remote from each repo in an entire directory stucture, and save those remotes and the directories they belong in to a file. Given the above example, it might look something like this:
./allaboutcheetahs.info email@example.com:dmuth/dmuth.github.io.git ./diceware firstname.lastname@example.org:dmuth/diceware.git ./docker/check-disk-space email@example.com:dmuth/docker-check-disk-usage.git ./docker/health-check firstname.lastname@example.org:dmuth/docker-health-check.git ./node/circuitbreaker-demo email@example.com:dmuth/another-circuit-breaker.git ./node/neural-network firstname.lastname@example.org:dmuth/neural-network.git ./s3/bucket-sizes email@example.com:dmuth/s3-bucket-sizes.git ./s3/disk-usage firstname.lastname@example.org:dmuth/s3-disk-usage.git ./snowdrift email@example.com:Comcast/snowdrift.git ./ssh-to firstname.lastname@example.org:Comcast/ssh-to.gitContinue reading “Saving and Restoring Your development/ Directory”