Created
July 29, 2024 12:35
-
-
Save oxcar103/70af50fa510b018947a0b2c832e1787d to your computer and use it in GitHub Desktop.
Changing git config user.email in all the subdirectories at same time
This file contains 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 | |
# 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