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 firstname.lastname@example.org:dmuth/dmuth.github.io.git ./diceware email@example.com:dmuth/diceware.git ./docker/check-disk-space firstname.lastname@example.org:dmuth/docker-check-disk-usage.git ./docker/health-check email@example.com:dmuth/docker-health-check.git ./node/circuitbreaker-demo firstname.lastname@example.org:dmuth/another-circuit-breaker.git ./node/neural-network email@example.com:dmuth/neural-network.git ./s3/bucket-sizes firstname.lastname@example.org:dmuth/s3-bucket-sizes.git ./s3/disk-usage email@example.com:dmuth/s3-disk-usage.git ./snowdrift firstname.lastname@example.org:Comcast/snowdrift.git ./ssh-to email@example.com:Comcast/ssh-to.gitContinue reading “Saving and Restoring Your development/ Directory”