git在没有设置全局别名的话,将多个项目下设置相同的别名的脚本
bash
复制代码
#!/bin/bash
# List of aliases to add
aliases=(
"co = checkout"
"ci = commit"
# Add more aliases here as needed
)
# Loop through each directory in the current directory
for dir in */; do
# Enter the directory
cd "$dir"
# Check if it's a Git repository
if [ -d ".git" ]; then
# Enter the Git repository
cd .git
# Add aliases to the local config file
for alias in "${aliases[@]}"; do
git config --local alias."${alias%%=*}" "${alias#*=}"
done
# Go back to the parent directory
cd ..
fi
done