Skip to content

Instantly share code, notes, and snippets.

@passsy
Created April 13, 2017 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save passsy/92c68c0165c9c73ffeacaf0f6a8a9b6c to your computer and use it in GitHub Desktop.
Save passsy/92c68c0165c9c73ffeacaf0f6a8a9b6c to your computer and use it in GitHub Desktop.
Create an archive of our source code without git history (including all submodules)
#!/bin/sh
# Check if 7zip is installed and install it if not
hash 7z 2>/dev/null || {
echo >&2 "7z is required to be installed";
echo "I will install it for you";
brew install p7zip;
}
# Read the commit sha
read -e -p "Enter the commit sha
=> " commit_sha
# Read the archive name
read -e -p "Enter the archive name (without file extension .7z)
=> " archive_name
repoUrl=$(git config --get remote.origin.url)
# clone git repo to desktop and do the work there
rm -rf ~/Desktop/repo-export
git clone $repoUrl ~/Desktop/repo-export
# goto cloned git repo
cd ~/Desktop/repo-export
# Checking out
#echo "Checking out $commit_sha"
git checkout $commit_sha
# update submodules
git submodule update --init --recursive
#echo "Removing \033[41;33;5mALL\033[0m git files"
# Hunting for git files and delete them
find . -name '.git*' -exec rm -rf '{}' \;
# Create the archive
cd ..
echo "Creating the archive"
7z a $archive_name repo-export/
#cleanup
rm -rf ~/Desktop/repo-export
echo "\nArchive created: ~/Desktop/"$archive_name".7z"
ls -al ${archive_name}.7z
pwd
echo "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment