Skip to content

Instantly share code, notes, and snippets.

@vgaidarji
Last active June 26, 2018 12:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgaidarji/49a0d515a3e28563e7fd32917e519fd3 to your computer and use it in GitHub Desktop.
Save vgaidarji/49a0d515a3e28563e7fd32917e519fd3 to your computer and use it in GitHub Desktop.
Update Git user name in sub-directories
#!/usr/bin/env sh
USER_NAME="Veaceslav Gaidarji"
USER_EMAIL="veaceslav.gaidarji@gmail.com"
echo "Using config: \n user.name=$USER_NAME, \n user.email=$USER_EMAIL\n"
for dir in */;
do
cd $dir
# update only if directory is git repo
if [ -d .git ] || [ git rev-parse --git-dir > /dev/null 2>&1 ]; then
git config user.name "$USER_NAME"
git config user.email "$USER_EMAIL"
git config commit.gpgsign true
echo "Git config updated in $dir"
fi;
cd ..
done
@vgaidarji
Copy link
Author

Run git config -l --local from Git repo folder to check local Git config.
Run git config -l --global from any folder to check global Git config.

Personally, I use local configs per organization, and global for every non-organization project.

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