-
-
Save qoomon/9177ff2080ba06a2a73acdd9f11b8c16 to your computer and use it in GitHub Desktop.
Git clone into non-empty directory
This file contains 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 | |
REPO_URL="$1" | |
TARGET_DIR="${2:-$(basename $REPO_URL .git)}" | |
SHADOW_DIR='.git.shadow' | |
cd $TARGET_DIR | |
git clone --no-checkout $REPO_URL $SHADOW_DIR | |
mv $SHADOW_DIR/.git . | |
rm -rf $SHADOW_DIR | |
git reset HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment