您的位置:首页 > 房产 > 家装 > 动漫网站模板设计图_sem是什么职业岗位_新闻式软文_百度网站怎么提升排名

动漫网站模板设计图_sem是什么职业岗位_新闻式软文_百度网站怎么提升排名

2024/12/22 2:38:04 来源:https://blog.csdn.net/xiongjia516/article/details/144293232  浏览:    关键词:动漫网站模板设计图_sem是什么职业岗位_新闻式软文_百度网站怎么提升排名
动漫网站模板设计图_sem是什么职业岗位_新闻式软文_百度网站怎么提升排名

文章目录

  • 1 A 仓库备份 到 B 仓库
  • 2 B 仓库修改main分支的权限

1 A 仓库备份 到 B 仓库

#!/bin/bash# 定义变量
REPO_DIR="/home/xhome/opt/git_sync/zz_xx_xx"  # 替换为你的本地库A的实际路径
REMOTE_ORIGIN="http://192.168.1.66:8181/zzkj_software/zz_xx_xx.git"        # 库A的URL
REMOTE_BACKUP="http://192.168.1.67:8181/zzkj_software/zz_xx_xx.git"  # 库B的URL
BRANCH_NAME="main"  # 分支名称# 进入仓库目录
cd "$REPO_DIR" || exit# 检查是否有新的提交到 REMOTE_BACKUP
echo "Checking for new commits on REMOTE_BACKUP..."
git fetch "$REMOTE_BACKUP" "$BRANCH_NAME"
if [ $(git rev-list --count HEAD...FETCH_HEAD) -gt 0 ]; thenecho "WARNING: There are new commits on REMOTE_BACKUP. These will be overwritten."read -p "Do you want to continue and force push? (y/n): " choiceif [ "$choice" != "y" ]; thenecho "Aborting."exit 1fi
fi# 获取最新的远程信息,并记录远程分支的最新提交哈希值
echo "Fetching the latest changes from REMOTE_BACKUP..."
git fetch "$REMOTE_BACKUP" "$BRANCH_NAME"
REMOTE_BRANCH_HASH=$(git rev-parse FETCH_HEAD)# 强制推送更新到远程备份库,使用 --force-with-lease 并指定预期的远程分支哈希值
echo "Pushing updates to REMOTE_BACKUP with --force-with-lease..."
if ! git push --force-with-lease="refs/heads/$BRANCH_NAME:$REMOTE_BRANCH_HASH" "$REMOTE_BACKUP" "$BRANCH_NAME"; thenecho "Failed to push updates to REMOTE_BACKUP. Please check your repository state."exit 1
fi# 强制推送所有标签到远程备份库
echo "Pushing tags to REMOTE_BACKUP..."
if ! git push "$REMOTE_BACKUP" --tags; thenecho "Failed to push tags to REMOTE_BACKUP. Please check your repository state."exit 1
fi# 可选:清理本地不再需要的远程跟踪分支和标签
# git remote prune backupecho "Synchronization completed successfully."

2 B 仓库修改main分支的权限

  • main 分支允许强制推送即可.
    在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com