Skip to content

Instantly share code, notes, and snippets.

@naranyala
Created August 17, 2023 08:29
Show Gist options
  • Save naranyala/c228478066fc5d841d05c43692e1a758 to your computer and use it in GitHub Desktop.
Save naranyala/c228478066fc5d841d05c43692e1a758 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Check if the script was invoked with at least one argument
if [ $# -eq 0 ]; then
echo "Usage: $0 <GitHub Repository URL> [Custom Repository Name]"
exit 1
fi
# Extract the repository name from the source URL
source_url="$1"
repo_name=$(basename "$source_url" .git)
# Check if a custom repository name is provided as the second argument
if [ $# -eq 2 ]; then
repo_name="$2"
fi
# Construct the git clone command
clone_command="git clone $source_url"
# Clone the repository
$clone_command
# Remove the .git directory from the cloned repository folder
rm -rf "$repo_name/.git"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment