Skip to content

Instantly share code, notes, and snippets.

@chunkhang
Created June 30, 2022 07:21
Show Gist options
  • Select an option

  • Save chunkhang/af3d8b309032c6632ede045a0f729f10 to your computer and use it in GitHub Desktop.

Select an option

Save chunkhang/af3d8b309032c6632ede045a0f729f10 to your computer and use it in GitHub Desktop.
Git clone that helps with creating folder structure
#!/bin/sh
# Create folder structure before cloning repository
#
# Example:
# Running `git clonex [email protected]:sygnum/securesite.git` is equivalent to:
# $ mkdir -p sygnum/securesite
# $ git clone [email protected]:sygnum/securesite.git sygnum/securesite
url="$1"
if [[ -z "$url" ]]; then
echo "usage: git clonex <repository url>"
exit 1
fi
path="$(echo "$url" | cut -d ':' -f 2- | sed 's/\.git$//')"
mkdir -p "$path"
git clone "$url" "$path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment