Skip to content

Instantly share code, notes, and snippets.

@jfsanchez91
Created September 7, 2017 14:06
Show Gist options
  • Save jfsanchez91/9b550643561a177574608ecde9f7f8e8 to your computer and use it in GitHub Desktop.
Save jfsanchez91/9b550643561a177574608ecde9f7f8e8 to your computer and use it in GitHub Desktop.
Bash function to zip a git project using git clone
#Author: Jorge Fernández Sánchez <jfsanchez.email@gmail.com>
#This function clone a git project and makes (in the working directory) a zip file with the project content.
#project packing from git
function git_pack {
_PWD=$PWD
GIT_PATH=$1
GIT_PROJECT=`/usr/bin/basename $GIT_PATH`
OUTPUT_ZIP="$_PWD/$GIT_PROJECT.zip"
TMP_PATH="/var/tmp/"
cd $TMP_PATH
TMP_PATH="$TMP_PATH/$GIT_PROJECT"
git clone $GIT_PATH
zip -r $OUTPUT_ZIP $GIT_PROJECT
cd $_PWD
rm -rf $TMP_PATH
echo "[SUCCESS] Project packed!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment