Skip to content

Instantly share code, notes, and snippets.

@denblackstache
Last active December 12, 2022 10:35
Show Gist options
  • Save denblackstache/fe102ed45a87e3b47864c703fe002ccc to your computer and use it in GitHub Desktop.
Save denblackstache/fe102ed45a87e3b47864c703fe002ccc to your computer and use it in GitHub Desktop.
Apply Git config to all directories in root directory
#!/bin/bash
set -euo pipefail
user_name="Denis S"
user_email="[email protected]"
ssh_command="ssh -i ~/.ssh/custom_key"
repo_container_path="/Users/den/repos"
configure_git_repo() {
custom_root_path=$1
if git -C "${custom_root_path}" status -s &>/dev/null
then
git -C "${custom_root_path}" config user.name "${user_name}"
git -C "${custom_root_path}" config user.email "${user_email}"
git -C "${custom_root_path}" config core.sshCommand "${ssh_command}"
else
echo "${custom_root_path} is not a Git repository"
fi
}
list_git_repos() {
find ${repo_container_path} -type d -maxdepth 1
}
list_git_repos | while read -r line ; do configure_git_repo "$line" ; done
echo "OK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment