Created
June 30, 2022 07:21
-
-
Save chunkhang/af3d8b309032c6632ede045a0f729f10 to your computer and use it in GitHub Desktop.
Git clone that helps with creating folder structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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