git——迁移方法备份

 

指定url导出 

export.sh

if [ -z "$1" ]
then
  echo "The origin_git_url is empty"
  exit
fi
origin_url=$1
echo ""
echo origin_url = $origin_url

filename=$(basename "$origin_url")

cd bare

if [ -d "$filename" ]; then
    echo "Folder $filename exists."
    exit
fi
# rm -rfv $filename
# echo "rm -rfv ok ...... "
git clone --bare $origin_url

 

批量导出 

export_all.sh

sh export.sh https://gitlab.inc.com/user.git
sh export.sh https://gitlab.inc.com/economy.git

 

向指定新git库导入

import.sh

if [ -z "$1" ]
then
  echo "group is empty"
  exit
fi

if [ -z "$2" ]
then
  echo "project name is empty"
  exit
fi

projname=$2

target_pre=http://10.1.2.6/

target_url=$target_pre$1"/"$projname

echo ""
echo target_url = $target_url
echo ""

cd bare
cd $projname
git push --mirror $target_url

 

批量导入 

import_all.sh

sh import.sh    group1     user.git
sh import.sh    group1     economy.git
sh import.sh    group2     basic.git

 

posted @ 2023-06-26 18:01  会飞的斧头  阅读(38)  评论(0编辑  收藏  举报