Skip to content

Instantly share code, notes, and snippets.

@martian17
Created February 21, 2022 09:13
Show Gist options
  • Save martian17/c47edf99b6956f1c5f13c6c54f63c43d to your computer and use it in GitHub Desktop.
Save martian17/c47edf99b6956f1c5f13c6c54f63c43d to your computer and use it in GitHub Desktop.
Pull a git module with sub modules without ssh permissions
#!/bin/bash
# first extracting the repository name
rep_regex="\\/([^\\/]*)\\.git$"
if [[ $1 =~ $rep_regex ]]
then
reponame="${BASH_REMATCH[1]}"
else
echo "$1 doesn't match" >&2 # this could get noisy if there are a lot of non-matching files
exit
fi
echo $reponame
rm -rf $reponame
git clone $1
cd $reponame
ls
sed -E "s/git@([^\:]+):/https:\/\/\1\//g" .gitmodules > .gitmodules1
mv .gitmodules1 .gitmodules
git submodule update --init --recursive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment