Something went wrong. Try again.
Dotfiles for my macos setup
Something went wrong. Try again.
1.2 kB · 36 lines
at main
12345678910111213141516171819202122232425262728293031323334353637#!/bin/bashset -e# Generic script to update all git submodules to their latest default branch (main/master)echo "Starting submodule update..."# Use git submodule foreach to iterate through all submodulesgit submodule foreach --recursive ' # Fetch latest references from origin git fetch origin -q # Detect the default branch (HEAD) from the remote # This handles repositories using "main", "master", or other default branch names TARGET_BRANCH=$(git remote show origin | grep "HEAD branch" | sed "s/.*: //") # Fallback if detection fails (unlikely on standard git servers) if [ -z "$TARGET_BRANCH" ]; then echo " Warning: Could not detect HEAD branch for $name. Trying main..." if git show-ref --verify --quiet refs/remotes/origin/main; then TARGET_BRANCH="main" else TARGET_BRANCH="master" fi fi echo " Processing $name: Checking out and pulling $TARGET_BRANCH" # Checkout the target branch git checkout "$TARGET_BRANCH" -q # Pull the latest changes git pull origin "$TARGET_BRANCH" -q'echo "All submodules updated successfully."