Skip to content

Instantly share code, notes, and snippets.

@oxcar103
Created July 29, 2024 12:35
Show Gist options
  • Save oxcar103/70af50fa510b018947a0b2c832e1787d to your computer and use it in GitHub Desktop.
Save oxcar103/70af50fa510b018947a0b2c832e1787d to your computer and use it in GitHub Desktop.
Changing git config user.email in all the subdirectories at same time
#!/bin/bash
# Check if an email address is provided as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <email>"
exit 1
fi
email="$1"
# Iterate over all directories in the current directory
for dir in */ ; do
if [ -d ]; then
cd $dir || continue
# Check if it's a Git repository
if [ -d ".git" ]; then
current_email=$(git config user.email)
if [ "$current_email" != "$email" ]; then
git config user.email "$email"
echo "Updated user.email in $dir"
fi
fi
cd ..
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment