Skip to content

Instantly share code, notes, and snippets.

@plasticut
Created November 11, 2021 08:32
Show Gist options
  • Save plasticut/c5616265cefac44972c9f7c6c6d810eb to your computer and use it in GitHub Desktop.
Save plasticut/c5616265cefac44972c9f7c6c6d810eb to your computer and use it in GitHub Desktop.
Make git repository bundle
#!/bin/bash
REPO_SSH_URL=$1
if [ "$REPO_SSH_URL" == "" ];
then
echo "Enter ssh git repo url"
exit 1;
fi
REPO_PATH=$(echo $REPO_SSH_URL | sed 's/^\(git@[A-z.]*\):\([0-9A-z/.-]*\)/\2/')
BUNDLE_FILE=$(echo "$REPO_PATH" | sed 's/^\([A-z]*\/\)\([A-z\.]*\)/\2/').bundle
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
echo "REPO_PATH = $REPO_PATH"
echo "BUNDLE_FILE = $BUNDLE_FILE"
mkdir -p $REPO_PATH
git clone --mirror $REPO_SSH_URL $REPO_PATH
cd $REPO_PATH
git bundle create $BUNDLE_FILE --all
mv $BUNDLE_FILE $SCRIPT_DIR/$BUNDLE_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment