I frequently find that I have old projects that I don't necessarily want ot delete, but I want to get out of the way. This is my setup to make that easy.
My setup has two parts: A repo (ex. ariporad/archive
), and a script (this one):
- The repo This repo is a collection of orphan branches, one per project. Since some of these projects are private (and I'm lazy), the entire repo is private.
- The script
This script takes the name of a file/folder ($folder) as an argument. It then:
- Zipps it into a temporary directory ($tmpdir), and appends the datetime to the folder name.
- Creates a new git repo in $tmpdir, and commits everything.
- Adds the archive repo as a remote
- Tries to push to $branch ($branch = $folder, all lowercase).
- If that fails, it: 1. Fetches origin 2. Rebases onto origin/$branch 3. Pushes again (if that fails, display an error and exit).
- Deletes $tmpdir
This was really useful for me, and it also cleaned up some hard drive space, which I was lacking. I hope you like it.
MIT licensed.