2022-10-24发表2023-12-26更新Linux / TIL1 分钟读完 (大约153个字)How to mirror a git repo Running in BKCI ./mirror-git-repo.sh123456789101112131415161718192021222324252627#!/bin/bash[[ "$IS_TRACE" == "true" ]] && set -xset -euWORK_DIR="${WORKSPACE}/${BK_CI_BUILD_ID}"mkdir -p ${WORK_DIR}cd ${WORK_DIR}# Create a bare clone of the origin repogit clone --progress --bare ${ORIGIN_GIT_URL}cd $(basename ${ORIGIN_GIT_URL})# Mirror-push to the target repogit push --force --progress --mirror https://${TARGET_GIT_USER_NAME}:${TARGET_GIT_ACCESS_TOKEN}@$(echo "${TARGET_GIT_URL}" | awk -F'^http[s]?://' '{print $2}')if [ "$IS_ENABLE_GIT_LFS" == 'true' ]; then git lfs install || exit 1 # Pull in the repo's Git lfs Storage objects. git lfs fetch --all # Push the repo's Git lfs objects to target repo. git lfs push --all https://${TARGET_GIT_USER_NAME}:${TARGET_GIT_ACCESS_TOKEN}@$(echo "${TARGET_GIT_URL}" | awk -F'^http[s]?://' '{print $2}')fisetEnv "BK_CI_BUILD_REMARK" "${ORIGIN_GIT_URL} to ${TARGET_GIT_URL}"How to mirror a git repohttps://1.not.icu/How-to-mirror-a-git-repo/作者Sony Dog发布于2022-10-24更新于2023-12-26许可协议CC BY-NC-SA 4.0 Git