Skip to content

Instantly share code, notes, and snippets.

@armadsen
Created July 19, 2017 02:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save armadsen/e534971c643d88309e14a8d40196bcfa to your computer and use it in GitHub Desktop.
Save armadsen/e534971c643d88309e14a8d40196bcfa to your computer and use it in GitHub Desktop.
Quick and dirty bash script to recursively commit submodules
if [[ "$#" -ne 1 ]]; then
echo "You must specify a commit message as an argument."
exit 1
fi
COMMIT_MESSAGE="$1"
git submodule foreach "echo 'Adding all files.'; git add ."
git submodule foreach "echo 'Stashing.'; git stash"
git submodule foreach "echo 'Checking out master branch.'; git checkout master"
git submodule foreach "echo 'Applying stash.'; git stash apply"
git submodule foreach "echo 'Readding all files.'; git add ."
git submodule foreach "echo 'Committing changes.'; git commit -a -q -m '${COMMIT_MESSAGE}' || :"
echo 'Adding main repo changes.'
git add .
echo 'Committing changes to main repo.'
git commit -a -m "${COMMIT_MESSAGE}"
@ameaninglessname
Copy link

ameaninglessname commented Oct 5, 2022

maybe there is something wrong in my local computer, this didn't work for me (still, thanks for your sharing!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment