Created
May 13, 2024 18:01
-
-
Save bjorg/3e6cda45943759176ff20374bc0db28e to your computer and use it in GitHub Desktop.
Script for running 'git pull' in every folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Default to the current directory if no directory is provided | |
REPO_DIR="${1:-.}" | |
# Check if the directory exists | |
if [ ! -d "$REPO_DIR" ]; then | |
echo "Directory does not exist: $REPO_DIR" | |
exit 1 | |
fi | |
# Navigate to the directory | |
cd "$REPO_DIR" | |
# Loop through each subdirectory and run 'git pull' | |
for dir in */ ; do | |
if [ -d "$dir/.git" ]; then # Check if it's a git repo | |
echo "Pulling in $dir" | |
cd "$dir" | |
git pull | |
cd .. | |
else | |
echo "Skipping $dir - not a git repository." | |
fi | |
done | |
echo "Git pull complete for all repositories." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment