ÎÒ¸öÈ˵Äϰ¹ßʱ½«ËùÓеÄgit²Ö¿â¶¼·ÅÔÚÒ»¸ö½Ð×örepositoryµÄĿ¼Ï¡£Èç¹ûͨ¹ýÒ»¸ö¸ö¼ì²é¸ÃĿ¼ÏÂdirs/.git/configϵĵØÖ·£¬È»ºóÒ»ÌõÌõgit clone À´ÔÚÁíһ̨»úÆ÷ÉÏÖØ½¨²Ö¿âĿ¼ÏÔµÃÓеãÌ«²»×¨ÒµÁË£¬ËùÒÔÎÒдÁ˸ö·Ç³£¼òµ¥µÄ½Å±¾£¨my_repository.sh£©¶ÁÈ¡²Ö¿âÖеĵØÖ·£¬²¢°ÑËùÓеØÖ·¶¼×·¼Óµ½Ò»¸öÎļþÖУ¬È»ºóʹÓÃÁíÍâÒ»¸ö½Å±¾(clone.sh)¶ÔÕâ¸öÎļþÖÐËùÓеĵØÖ·½øÐÐgit clone £¬ºÜ¼òµ¥¡£
Ê×ÏÈ£¬¿´Ò»ÏÂËѼ¯git²Ö¿âµØÖ·µÄshell½Å±¾£º[code]#!/bin/bash
# (C) 2014 Yunlong Zhou
# Under licence GPL
# File : my_repository.sh
# Introduction:
# This script is using for collect all the git address to a file -- repository_file
# Useage :
# 1. cd repository -- cd to the dir that you store all the git repository
# 2. chmox +x my_repository.sh -- give the script a execute permission
# 3. ./my_repository.sh
# for delete old temp file ,if there is !
if [ -f all_dir -a -f repository_file ]; then
echo "Now delete old temp file"
rm all_dir repository_file 2> /dev/null
fi
# read all the items under this dir to the file all_dir
ls -l | awk '{print $9}' > all_dir
# deal with every git repository dir and collect the url then store to file repository_file
while read FILE_NAME
do
if [ $FILE_NAME != " " -a -d $FILE_NAME -a -s $FILE_NAME ];then
echo "Now dealing the "$FILE_NAME
if [ -d $FILE_NAME/.git ]; then
grep -e "url" $FILE_NAME/.git/config | cut -d "=" -f2 | cut -d " " -f2 >>repository_file
fi
fi
done < all_dir
# remove temp file and give a Hint !
rm all_dir
if [ $? == 0 ]; then
echo "Ok,all the url of your repository have been send to file -- repository_file"
fi[/code]ÏÖÔÚ£¬ËùÓвֿâĿ¼ÏµÄgit²Ö¿âµØÖ·ÒѾ±»Ìí¼Óµ½repository_fileÎļþÖУ¬È磺
linux@zhouyl:~/repository$ cat repository_file
git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
git://gitorious.org/tinylab/pleac-shell.git
git://git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git
...
ÕâÀïÊ¡ÂÔÁËÊ®¼¸¸ö¸öÈ˲ֿâ
ÏÖÔÚÎÒÃÇ¿ÉÒÔʹÓÃscp½«repository_fileÎļþÒÔ¼°¶ÔÏÂÃæµÄÕâ¸ö½Å±¾¿½±´µ½Ð°²×°µÄµçÄÔÉÏ(scp repository_file clone.sh linux@192.168.2.110:/tmp/)£¬È»ºóÖ±½ÓÔËÐÐclone.sh£¨./clone.sh£©¼´¿É£¡[code]#!/bin/bash
# (C) 2014 Yunlong Zhou
# Under licence GPL
# File : clone.sh
# Introduction:
# This script is using for git clone every item in repository_file
# Useage :
# 1. ./clone.sh
if [ ! -f repository_file ]; then
echo "There is no repository_file ,we will exit"
exit
fi
while read READLINE
do
echo "Now we will clone $READLINE"
git clone $READLINE
done < repository_file
rm repository_file[/code]×÷Õߣºlongerzone