歡迎訪問我的博客难衰,同步更新: 楓山別院
有時候在某個目錄下有很多git工程捏卓,每次一個個的git pull非常的不方便,所以寫了一個小腳本否纬,每次運行一下就可以了吕晌,相當(dāng)方便,如下
#!/bin/bash
function showMsg()
{
echo -e "\033[32m$1\033[0m"
}
function getdir(){
for element in `ls $1`
do
dir_or_file=$1"/"$element
if [ -d $dir_or_file ]
then
cd $1"/"$element
showMsg 'git pull '$element
git pull
else
echo $dir_or_file
fi
done
}
root_dir="/Users/scott/Documents/code"
getdir $root_dir
只要替換一下root_dir的路徑就可以了
將git pull 替換一下临燃,就可以作為另一個腳本使用睛驳,比如,替換為 git gc 可以壓縮 git 庫