Skip to content

Instantly share code, notes, and snippets.

@e3krisztian
Last active December 31, 2015 05:49
Show Gist options
  • Save e3krisztian/7943250 to your computer and use it in GitHub Desktop.
Save e3krisztian/7943250 to your computer and use it in GitHub Desktop.
zip up files not yet added to git (they should be data files or other residue)
#!/bin/bash
# requires sponge from Debian(?) package moreutils
set -x
project=$(basename $(pwd))
date=$(date +%Y%m%d)
zipfile=${project}-${USER}-data-${date}.zip
zipargs=(
--suffixes .gz:.bz2:.zip:.rar # these are stored without further compression
--names-stdin # read files & directories to add from stdin
--recurse-paths # add contents of directories, too
--symlinks # store them
--test # test output after creating
--move # remove files after zip file created & tested
)
git status --porcelain |
grep '^[?][?] ' | # keep only unknown files
sed 's/^?? //' | # (remove flags)
sponge | # paranoia: prevent zip temporary file to be listed
zip ${zipfile} "${zipargs[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment