公司Android dailybuild服务器上,没有对所有目录建立git服务,只有某些目录有,所以无法一次同步所有的代码.
于是我就想先找到所有的.git目录,然后有它的上一级目录执行git pull,这样就能将这个目录同步更新了,用一个循环,就能实现所有的git目录同步了

root@ubuntu:~/shell# cat gitsync.sh
#!/bin/sh
GIT_DIR_LIST=~/gitdirlist.txt

echo "find /ruby/ -iname ".git" >${GIT_DIR_LIST}"
find /ruby/ -iname ".git" >${GIT_DIR_LIST}
n=`wc ${GIT_DIR_LIST}|cut -d " " -f2`
count=0


for i in `cat ${GIT_DIR_LIST}`
do
count=`expr ${count} + 1`
echo "Sync ${count}/${n} "
echo "cd ${i},then git pull"
cd ${i}/..&&git pull
done
批量git pull脚本

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.