想要修改 100 多個的項目的 git 配置三圆,這 100 多個項目在同一個目錄下。
可以用 shell 腳本來實現(xiàn)。
新建一個 change-user.sh
摊鸡,添加以下的內(nèi)容津坑。
#/usr/env/sh
for dir in `find ./* -type d -maxdepth 0`; do
cd ${dir}
git config user.name stephen.xu
git config user.email stephen.xu@dianping.com
echo `pwd`
cd ..
done
使用 find
來遍歷文件
使用 find ./*
而不是 find .
來剔除 .
目錄
使用 -type d
來保證搜索到的結(jié)果是目錄
使用 -maxdepth 0
來保證搜索到的目錄是當前目錄下的一級目錄