Skip to content

Instantly share code, notes, and snippets.

@Rod911
Last active April 29, 2023 18:04
Show Gist options
  • Save Rod911/9f08e503a6da19c5c93c9867ae77247e to your computer and use it in GitHub Desktop.
Save Rod911/9f08e503a6da19c5c93c9867ae77247e to your computer and use it in GitHub Desktop.
Create zip file of git changes in working directory
#!/bin/bash
CURRENT=`pwd`
BASENAME=`basename "$CURRENT"`
ZIPPATH="D:/xampp74/htdocs/modified-files"
mkdir -p $ZIPPATH/$BASENAME
if [ -e $ZIPPATH/$BASENAME.zip ]
then
echo "Removing old zip"
rm -r $ZIPPATH/$BASENAME.zip
else
echo "Old zip doesn't exist"
fi
echo "Copying"
cp --parents $(git ls-files --modified --others --exclude-standard) $ZIPPATH/$BASENAME
echo "Staging"
git add $(git ls-files --modified --others --exclude-standard)
echo "Zipping $ZIPPATH/$BASENAME"
cd $ZIPPATH/$BASENAME
zip -r $ZIPPATH/$BASENAME.zip "*"
# cd D:/xampp74/htdocs/$BASENAME
echo "Deleting copied files"
rm -r $ZIPPATH/$BASENAME
echo "Done"
# open in explorer
start "$ZIPPATH"
echo "Explorer open $ZIPPATH"
# explorer.exe /e,/select, "$ZIPPATH/$BASENAME.zip"
# echo "Explorer open $ZIPPATH/$BASENAME.zip"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment