Skip to content

Instantly share code, notes, and snippets.

@dogukanarat
Created November 15, 2024 11:18
Show Gist options
  • Save dogukanarat/15ea76022d3cca368537b2f34f22964c to your computer and use it in GitHub Desktop.
Save dogukanarat/15ea76022d3cca368537b2f34f22964c to your computer and use it in GitHub Desktop.
Script file to extract all git submodule and create text file that contains git command to initialize them
#!/bin/sh
set -e
output_file="submodule_add_commands.sh"
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key local_path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
command="git submodule add $url $local_path"
echo "$command"
echo "$command" >> "$output_file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment