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 @   会飞的斧头  阅读(52)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示